diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-03-24 12:29:55 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-03-24 12:29:55 +0100 |
commit | c12001a574e7858060a91019dc28bdf137894065 (patch) | |
tree | 8331c88e7205e2382da089edccefad71c42db8eb /libimagrt | |
parent | ba0d95233305ae734dc852d4e3a79a48ac7b42d8 (diff) |
Remove unwraphell and replace by try!()
Diffstat (limited to 'libimagrt')
-rw-r--r-- | libimagrt/src/edit.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/libimagrt/src/edit.rs b/libimagrt/src/edit.rs index a34a4bf1..73529b53 100644 --- a/libimagrt/src/edit.rs +++ b/libimagrt/src/edit.rs @@ -37,24 +37,13 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> EditResult<()> { use std::io::SeekFrom; use std::io::Write; - let file = NamedTempFile::new(); - if file.is_err() { - return Err(RuntimeError::new(RuntimeErrorKind::Instantiate, None)); - } - let file = file.unwrap(); + let file = try!(NamedTempFile::new()); let file_path = file.path(); - let file = file.reopen(); - - if file.is_err() { - return Err(RuntimeError::new(RuntimeErrorKind::IOError, Some(Box::new(file.err().unwrap())))); - } + let mut file = try!(file.reopen()); - let mut file = file.unwrap(); file.write_all(&s.clone().into_bytes()[..]); - if let Err(e) = file.sync_data() { - return Err(RuntimeError::new(RuntimeErrorKind::IOError, Some(Box::new(e)))); - } + try!(file.sync_data()); if let Some(mut editor) = rt.editor() { let exit_status = editor.arg(file_path).status(); |