Make code more idomatic

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2018-11-07 17:30:46 +01:00
parent 8d0ae1058e
commit ed469f622a
2 changed files with 15 additions and 23 deletions

View file

@ -32,13 +32,9 @@ pub struct SetEndTimeIter<'a> {
datetime: NDT, datetime: NDT,
} }
impl<'a> SetEndTimeIter<'a> impl<'a> SetEndTimeIter<'a> {
{
pub fn new(inner: CreateTimeTrackIter<'a>, datetime: NDT) -> SetEndTimeIter<'a> { pub fn new(inner: CreateTimeTrackIter<'a>, datetime: NDT) -> SetEndTimeIter<'a> {
SetEndTimeIter { SetEndTimeIter { inner, datetime }
inner: inner,
datetime: datetime,
}
} }
} }
@ -48,13 +44,11 @@ impl<'a> Iterator for SetEndTimeIter<'a> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
self.inner self.inner
.next() .next()
.map(|res| { .map(|res| res.and_then(|mut fle| {
res.and_then(|mut fle| { let v = Value::String(self.datetime.format(DATE_TIME_FORMAT).to_string());
let v = Value::String(self.datetime.format(DATE_TIME_FORMAT).to_string()); let _ = fle.get_header_mut().insert(DATE_TIME_END_HEADER_PATH, v)?;
let _ = fle.get_header_mut().insert(DATE_TIME_END_HEADER_PATH, v)?; Ok(fle)
Ok(fle) }))
})
})
} }
} }

View file

@ -57,16 +57,14 @@ impl Iterator for TagStoreIdIter {
self.inner self.inner
.next() .next()
.map(|res| { .map(|res| res.and_then(|tag| {
res.and_then(|tag| { let dt = self.datetime.format(DATE_TIME_FORMAT).to_string();
let dt = self.datetime.format(DATE_TIME_FORMAT).to_string(); let id_str = format!("{}-{}", dt, tag.as_str());
let id_str = format!("{}-{}", dt, tag.as_str()); ModuleEntryPath::new(id_str)
ModuleEntryPath::new(id_str) .into_storeid()
.into_storeid() .map_err(Error::from)
.map_err(Error::from) .map(|id| (id, self.datetime.clone()))
.map(|id| (id, self.datetime.clone())) }))
})
})
} }
} }