mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
install: use map_err instead of if let Err
This commit is contained in:
parent
74d04c26f0
commit
64d308db0e
1 changed files with 3 additions and 5 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue