Skip to content

Commit

Permalink
mv: refactor try! to ?
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Feb 9, 2019
1 parent fb1d844 commit 52c7f0a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/mv/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
BackupMode::ExistingBackup => Some(existing_backup_path(to, &b.suffix)),
};
if let Some(ref p) = backup_path {
try!(fs::rename(to, p));
fs::rename(to, p)?;
}

if b.update {
if try!(try!(fs::metadata(from)).modified()) <= try!(try!(fs::metadata(to)).modified())
if fs::metadata(from)?.modified()? <= fs::metadata(to)?.modified()?
{
return Ok(());
}
Expand All @@ -374,14 +374,14 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
// normalize behavior between *nix and windows
if from.is_dir() {
if is_empty_dir(to) {
try!(fs::remove_dir(to))
fs::remove_dir(to)?
} else {
return Err(std::io::Error::new(std::io::ErrorKind::Other, "Directory not empty"));
}
}
}

try!(fs::rename(from, to));
fs::rename(from, to)?;

if b.verbose {
print!("‘{}’ -> ‘{}’", from.display(), to.display());
Expand Down

0 comments on commit 52c7f0a

Please sign in to comment.