From c02d7693b24a37c6bc02beccefe1803e34adbac2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 3 Nov 2016 20:21:31 -0700 Subject: [PATCH] Don't re-open temporary file. `Write` is implemented on both `&NamedTemporaryFile` and `&File` so you don't actually need a mutable reference. I wish there were a better way to do this but such is life. --- libimagutil/src/edit.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libimagutil/src/edit.rs b/libimagutil/src/edit.rs index 3cf459f4..5d1838fc 100644 --- a/libimagutil/src/edit.rs +++ b/libimagutil/src/edit.rs @@ -27,9 +27,8 @@ use std::io::Error as IOError; use tempfile::NamedTempFile; pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result { - let file = try!(NamedTempFile::new()); + let mut file = &try!(NamedTempFile::new()); let file_path = file.path(); - let mut file = try!(file.reopen()); try!(file.write_all(&s.clone().into_bytes()[..])); try!(file.sync_data());