Skip to content

Commit cf63374

Browse files
committed
Avoid trivial wrapper functions
1 parent 66b5060 commit cf63374

File tree

4 files changed

+9
-33
lines changed

4 files changed

+9
-33
lines changed

src/dist/component/components.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl Component {
194194
let temp = tx.temp().new_file()?;
195195
utils::filter_file("components", &abs_path, &temp, |l| l != self.name)?;
196196
tx.modify_file(path)?;
197-
utils::rename_file("components", &temp, &abs_path, tx.notify_handler())?;
197+
utils::rename("components", &temp, &abs_path, tx.notify_handler())?;
198198

199199
// TODO: If this is the last component remove the components file
200200
// and the version file.

src/dist/component/transaction.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ impl<'a> ChangedItem<'a> {
222222
AddedFile(path) => utils::remove_file("component", &prefix.abs_path(path))?,
223223
AddedDir(path) => utils::remove_dir("component", &prefix.abs_path(path), notify)?,
224224
RemovedFile(path, tmp) | ModifiedFile(path, Some(tmp)) => {
225-
utils::rename_file("component", tmp, &prefix.abs_path(path), notify)?
225+
utils::rename("component", tmp, &prefix.abs_path(path), notify)?
226226
}
227227
RemovedDir(path, tmp) => {
228-
utils::rename_dir("component", &tmp.join("bk"), &prefix.abs_path(path), notify)?
228+
utils::rename("component", &tmp.join("bk"), &prefix.abs_path(path), notify)?
229229
}
230230
ModifiedFile(path, None) => {
231231
let abs_path = prefix.abs_path(path);
@@ -292,7 +292,7 @@ impl<'a> ChangedItem<'a> {
292292
}
293293
.into())
294294
} else {
295-
utils::rename_file("component", &abs_path, &backup, notify)?;
295+
utils::rename("component", &abs_path, &backup, notify)?;
296296
Ok(ChangedItem::RemovedFile(relpath, backup))
297297
}
298298
}
@@ -312,7 +312,7 @@ impl<'a> ChangedItem<'a> {
312312
}
313313
.into())
314314
} else {
315-
utils::rename_dir("component", &abs_path, &backup.join("bk"), notify)?;
315+
utils::rename("component", &abs_path, &backup.join("bk"), notify)?;
316316
Ok(ChangedItem::RemovedDir(relpath, backup))
317317
}
318318
}
@@ -342,7 +342,7 @@ impl<'a> ChangedItem<'a> {
342342
notify: &'a dyn Fn(Notification<'_>),
343343
) -> Result<Self> {
344344
let abs_path = ChangedItem::dest_abs_path(prefix, component, &relpath)?;
345-
utils::rename_file("component", src, &abs_path, notify)?;
345+
utils::rename("component", src, &abs_path, notify)?;
346346
Ok(ChangedItem::AddedFile(relpath))
347347
}
348348
fn move_dir(
@@ -353,7 +353,7 @@ impl<'a> ChangedItem<'a> {
353353
notify: &'a dyn Fn(Notification<'_>),
354354
) -> Result<Self> {
355355
let abs_path = ChangedItem::dest_abs_path(prefix, component, &relpath)?;
356-
utils::rename_dir("component", src, &abs_path, notify)?;
356+
utils::rename("component", src, &abs_path, notify)?;
357357
Ok(ChangedItem::AddedDir(relpath))
358358
}
359359
}

src/dist/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'a> DownloadCfg<'a> {
106106
} else {
107107
(self.notify_handler)(Notification::ChecksumValid(url.as_ref()));
108108

109-
utils::rename_file(
109+
utils::rename(
110110
"downloaded",
111111
&partial_file_path,
112112
&target_file,

src/utils/utils.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,6 @@ pub(crate) fn write_str(name: &'static str, file: &mut File, path: &Path, s: &st
9090
})
9191
}
9292

93-
pub fn rename_file<'a, N>(
94-
name: &'static str,
95-
src: &'a Path,
96-
dest: &'a Path,
97-
notify: &'a dyn Fn(N),
98-
) -> Result<()>
99-
where
100-
N: From<Notification<'a>>,
101-
{
102-
rename(name, src, dest, notify)
103-
}
104-
105-
pub(crate) fn rename_dir<'a, N>(
106-
name: &'static str,
107-
src: &'a Path,
108-
dest: &'a Path,
109-
notify: &'a dyn Fn(N),
110-
) -> Result<()>
111-
where
112-
N: From<Notification<'a>>,
113-
{
114-
rename(name, src, dest, notify)
115-
}
116-
11793
pub(crate) fn filter_file<F: FnMut(&str) -> bool>(
11894
name: &'static str,
11995
src: &Path,
@@ -541,7 +517,7 @@ where
541517
}
542518
}
543519

544-
fn rename<'a, N>(
520+
pub fn rename<'a, N>(
545521
name: &'static str,
546522
src: &'a Path,
547523
dest: &'a Path,

0 commit comments

Comments
 (0)