From f82ad2b6d1db3dbc84e1af4a2a4dabf23e31b1cc Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 30 Oct 2017 20:19:29 +0100 Subject: [PATCH] Replace uses of try!() macro with "?" operator --- lib/domain/libimagtodo/src/taskstore.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/domain/libimagtodo/src/taskstore.rs b/lib/domain/libimagtodo/src/taskstore.rs index 0b9cca03..9febe2e1 100644 --- a/lib/domain/libimagtodo/src/taskstore.rs +++ b/lib/domain/libimagtodo/src/taskstore.rs @@ -54,7 +54,7 @@ impl<'a> TaskStore<'a> for Store { fn import_task_from_reader(&'a self, mut r: R) -> Result<(FileLockEntry<'a>, String, Uuid)> { let mut line = String::new(); - try!(r.read_line(&mut line).map_err(|_| TE::from_kind(TEK::UTF8Error))); + r.read_line(&mut line).map_err(|_| TE::from_kind(TEK::UTF8Error))?; import_task(&line.as_str()) .map_err(|_| TE::from_kind(TEK::ImportError)) .and_then(|t| { @@ -74,7 +74,7 @@ impl<'a> TaskStore<'a> for Store { /// fn get_task_from_import(&'a self, mut r: R) -> Result, String>> { let mut line = String::new(); - try!(r.read_line(&mut line).chain_err(|| TEK::UTF8Error)); + r.read_line(&mut line).chain_err(|| TEK::UTF8Error)?; self.get_task_from_string(line) } @@ -107,7 +107,7 @@ impl<'a> TaskStore<'a> for Store { /// implicitely create the task if it does not exist. fn retrieve_task_from_import(&'a self, mut r: R) -> Result> { let mut line = String::new(); - try!(r.read_line(&mut line).chain_err(|| TEK::UTF8Error)); + r.read_line(&mut line).chain_err(|| TEK::UTF8Error)?; self.retrieve_task_from_string(line) } @@ -186,14 +186,14 @@ impl<'a> TaskStore<'a> for Store { .and_then(|mut fle| { { let hdr = fle.get_header_mut(); - if try!(hdr.read("todo").chain_err(|| TEK::StoreError)).is_none() { - try!(hdr + if hdr.read("todo").chain_err(|| TEK::StoreError)?.is_none() { + hdr .set("todo", Value::Table(BTreeMap::new())) - .chain_err(|| TEK::StoreError)); + .chain_err(|| TEK::StoreError)?; } - try!(hdr.set("todo.uuid", Value::String(format!("{}",uuid))) - .chain_err(|| TEK::StoreError)); + hdr.set("todo.uuid", Value::String(format!("{}",uuid))) + .chain_err(|| TEK::StoreError)?; } // If none of the errors above have returned the function, everything is fine