1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

install: use map_err instead of if let Err

This commit is contained in:
Daniel Hofstetter 2025-05-02 07:50:50 +02:00 committed by Sylvestre Ledru
parent 74d04c26f0
commit 64d308db0e

View file

@ -730,11 +730,9 @@ fn perform_backup(to: &Path, b: &Behavior) -> UResult<Option<PathBuf>> {
} }
let backup_path = backup_control::get_backup_path(b.backup_mode, to, &b.suffix); let backup_path = backup_control::get_backup_path(b.backup_mode, to, &b.suffix);
if let Some(ref backup_path) = backup_path { if let Some(ref backup_path) = backup_path {
if let Err(err) = fs::rename(to, backup_path) { fs::rename(to, backup_path).map_err(|err| {
return Err( InstallError::BackupFailed(to.to_path_buf(), backup_path.clone(), err)
InstallError::BackupFailed(to.to_path_buf(), backup_path.clone(), err).into(), })?;
);
}
} }
Ok(backup_path) Ok(backup_path)
} else { } else {