Skip to content

Commit 64d308d

Browse files
cakebakersylvestre
authored andcommitted
install: use map_err instead of if let Err
1 parent 74d04c2 commit 64d308d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/uu/install/src/install.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,11 +730,9 @@ fn perform_backup(to: &Path, b: &Behavior) -> UResult<Option<PathBuf>> {
730730
}
731731
let backup_path = backup_control::get_backup_path(b.backup_mode, to, &b.suffix);
732732
if let Some(ref backup_path) = backup_path {
733-
if let Err(err) = fs::rename(to, backup_path) {
734-
return Err(
735-
InstallError::BackupFailed(to.to_path_buf(), backup_path.clone(), err).into(),
736-
);
737-
}
733+
fs::rename(to, backup_path).map_err(|err| {
734+
InstallError::BackupFailed(to.to_path_buf(), backup_path.clone(), err)
735+
})?;
738736
}
739737
Ok(backup_path)
740738
} else {

0 commit comments

Comments
 (0)