From ed469f622a2f0f2f478ad0689415d465f028de1c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Nov 2018 17:30:46 +0100 Subject: [PATCH] Make code more idomatic Signed-off-by: Matthias Beyer --- .../libimagtimetrack/src/iter/setendtime.rs | 20 +++++++------------ .../libimagtimetrack/src/iter/storeid.rs | 18 ++++++++--------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/lib/domain/libimagtimetrack/src/iter/setendtime.rs b/lib/domain/libimagtimetrack/src/iter/setendtime.rs index 3d2e4ca1..60040159 100644 --- a/lib/domain/libimagtimetrack/src/iter/setendtime.rs +++ b/lib/domain/libimagtimetrack/src/iter/setendtime.rs @@ -32,13 +32,9 @@ pub struct SetEndTimeIter<'a> { datetime: NDT, } -impl<'a> SetEndTimeIter<'a> -{ +impl<'a> SetEndTimeIter<'a> { pub fn new(inner: CreateTimeTrackIter<'a>, datetime: NDT) -> SetEndTimeIter<'a> { - SetEndTimeIter { - inner: inner, - datetime: datetime, - } + SetEndTimeIter { inner, datetime } } } @@ -48,13 +44,11 @@ impl<'a> Iterator for SetEndTimeIter<'a> { fn next(&mut self) -> Option { self.inner .next() - .map(|res| { - res.and_then(|mut fle| { - let v = Value::String(self.datetime.format(DATE_TIME_FORMAT).to_string()); - let _ = fle.get_header_mut().insert(DATE_TIME_END_HEADER_PATH, v)?; - Ok(fle) - }) - }) + .map(|res| res.and_then(|mut fle| { + let v = Value::String(self.datetime.format(DATE_TIME_FORMAT).to_string()); + let _ = fle.get_header_mut().insert(DATE_TIME_END_HEADER_PATH, v)?; + Ok(fle) + })) } } diff --git a/lib/domain/libimagtimetrack/src/iter/storeid.rs b/lib/domain/libimagtimetrack/src/iter/storeid.rs index 91656a3f..63728ad2 100644 --- a/lib/domain/libimagtimetrack/src/iter/storeid.rs +++ b/lib/domain/libimagtimetrack/src/iter/storeid.rs @@ -57,16 +57,14 @@ impl Iterator for TagStoreIdIter { self.inner .next() - .map(|res| { - res.and_then(|tag| { - let dt = self.datetime.format(DATE_TIME_FORMAT).to_string(); - let id_str = format!("{}-{}", dt, tag.as_str()); - ModuleEntryPath::new(id_str) - .into_storeid() - .map_err(Error::from) - .map(|id| (id, self.datetime.clone())) - }) - }) + .map(|res| res.and_then(|tag| { + let dt = self.datetime.format(DATE_TIME_FORMAT).to_string(); + let id_str = format!("{}-{}", dt, tag.as_str()); + ModuleEntryPath::new(id_str) + .into_storeid() + .map_err(Error::from) + .map(|id| (id, self.datetime.clone())) + })) } }