Use ? operator instead of try!() macro

This commit is contained in:
Matthias Beyer 2017-10-21 16:17:35 +02:00
parent 82c30edcee
commit 26d7fd4eb7

View file

@ -27,11 +27,11 @@ use std::io::Error as IOError;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result<bool, IOError> { pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result<bool, IOError> {
let mut file = &try!(NamedTempFile::new()); let mut file = &NamedTempFile::new()?;
let file_path = file.path(); let file_path = file.path();
try!(file.write_all(&s.clone().into_bytes()[..])); file.write_all(&s.clone().into_bytes()[..])?;
try!(file.sync_data()); file.sync_data()?;
cmd.arg(file_path) cmd.arg(file_path)
.status() .status()