diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-02-11 19:58:53 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-02-11 23:44:27 +0100 |
commit | 77be32d80f8ca60e10fe98f0eebf4bdf9de9f754 (patch) | |
tree | a02bf44dc54c445ca275e5a2ef80d7a994b5aea5 /bin/domain/imag-timetrack/src/week.rs | |
parent | f33768abbf7f84f06b60009f00cf4dab969939e9 (diff) |
Remove "get" iterator, store provides this now
Diffstat (limited to 'bin/domain/imag-timetrack/src/week.rs')
-rw-r--r-- | bin/domain/imag-timetrack/src/week.rs | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/bin/domain/imag-timetrack/src/week.rs b/bin/domain/imag-timetrack/src/week.rs index db085a67..32d83831 100644 --- a/bin/domain/imag-timetrack/src/week.rs +++ b/bin/domain/imag-timetrack/src/week.rs @@ -88,31 +88,32 @@ pub fn week(rt: &Runtime) -> i32 { rt.store() .get_timetrackings() - .and_then(|iter| { - iter.trace_unwrap() - .filter(|e| filter.filter(e)) - .fold(Ok(()), |acc, e| { - acc.and_then(|_| { - debug!("Processing {:?}", e.get_location()); - - let tag = e.get_timetrack_tag()?; - debug!(" -> tag = {:?}", tag); - - let start = e.get_start_datetime()?; - debug!(" -> start = {:?}", start); - - let end = e.get_end_datetime()?; - debug!(" -> end = {:?}", end); - - match (start, end) { - (None, _) => println!("{} has no start time.", tag), - (Some(s), None) => println!("{} | {} - ...", tag, s), - (Some(s), Some(e)) => println!("{} | {} - {}", tag, s, e), - } - - Ok(()) - }) - }) + .map_err_trace_exit_unwrap(1) + .trace_unwrap() + .filter(Option::is_some) + .map(Option::unwrap) + .filter(|e| filter.filter(e)) + .fold(Ok(()), |acc: Result<(), ::libimagtimetrack::error::TimeTrackError>, e| { + acc.and_then(|_| { + debug!("Processing {:?}", e.get_location()); + + let tag = e.get_timetrack_tag()?; + debug!(" -> tag = {:?}", tag); + + let start = e.get_start_datetime()?; + debug!(" -> start = {:?}", start); + + let end = e.get_end_datetime()?; + debug!(" -> end = {:?}", end); + + match (start, end) { + (None, _) => println!("{} has no start time.", tag), + (Some(s), None) => println!("{} | {} - ...", tag, s), + (Some(s), Some(e)) => println!("{} | {} - {}", tag, s, e), + } + + Ok(()) + }) }) .map(|_| 0) .map_err_trace() |