From c60d7a52353d5c89d6151bf97592c71f243aea9b Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Sat, 17 Sep 2016 03:34:06 -0700 Subject: [PATCH] Make file handle scope more explicit --- src/main.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index dc6dcb9..957763f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,12 +120,13 @@ Send files to the graveyard (/tmp/.graveyard) instead of unlinking them.") fn write_log(source: PathBuf, dest: PathBuf, graveyard: &Path) -> std::io::Result<()> { let histfile = graveyard.join(HISTFILE); - let mut f = try!(fs::File::create(histfile)); - try!(f.write_all( - format!("{}\t{}", - source.to_str().unwrap(), - dest.to_str().unwrap(), - ).as_bytes())); + { + let mut f = try!(fs::File::create(histfile)); + try!(f.write_all(format!("{}\t{}", + source.to_str().unwrap(), + dest.to_str().unwrap()) + .as_bytes())); + } Ok(()) }