diff --git a/lib/domain/libimagtimetrack/src/iter/get.rs b/lib/domain/libimagtimetrack/src/iter/get.rs index 526c1c97..739e07a2 100644 --- a/lib/domain/libimagtimetrack/src/iter/get.rs +++ b/lib/domain/libimagtimetrack/src/iter/get.rs @@ -45,11 +45,10 @@ impl<'a> Iterator for GetTimeTrackIter<'a> { fn next(&mut self) -> Option { self.inner.next().map(|sid| { - match self.store.get(sid).chain_err(|| TTEK::StoreReadError) { - Ok(None) => Err(TTE::from_kind(TTEK::StoreReadError)), - Ok(Some(s)) => Ok(s), - Err(e) => Err(e) - } + self.store + .get(sid) + .chain_err(|| TTEK::StoreReadError)? + .ok_or(TTE::from_kind(TTEK::StoreReadError)) }) } } diff --git a/lib/domain/libimagtimetrack/src/timetracking.rs b/lib/domain/libimagtimetrack/src/timetracking.rs index 7c3bf11d..bbf8b06f 100644 --- a/lib/domain/libimagtimetrack/src/timetracking.rs +++ b/lib/domain/libimagtimetrack/src/timetracking.rs @@ -65,11 +65,13 @@ impl TimeTracking for Entry { fn get_timetrack_tag(&self) -> Result { self.get_header() .read(DATE_TIME_TAG_HEADER_PATH) - .chain_err(|| TTEK::HeaderReadError) - .and_then(|value| match value { - Some(&Value::String(ref s)) => Ok(s.clone().into()), - Some(_) => Err(TTE::from_kind(TTEK::HeaderFieldTypeError)), - _ => Err(TTE::from_kind(TTEK::HeaderReadError)) + .chain_err(|| TTEK::HeaderReadError)? + .ok_or(TTE::from_kind(TTEK::HeaderReadError)) + .and_then(|v| { + v.as_str() + .map(String::from) + .map(Into::into) + .ok_or(TTE::from_kind(TTEK::HeaderFieldTypeError)) }) }