diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2018-11-04 22:28:47 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2018-11-06 14:48:49 +0100 |
commit | d004c667fd7ba901e156f7943d068fb8c785f81e (patch) | |
tree | 860eebdfa04a2f476e33aee0f99207355fa1d354 /bin | |
parent | 5210985bf4ec73fcaf0dde70c369055931414039 (diff) |
Optimize implementation
Code-wise, the functionality was not changed. The changes only make the
code much more pretty.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin')
-rw-r--r-- | bin/domain/imag-diary/src/delete.rs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/bin/domain/imag-diary/src/delete.rs b/bin/domain/imag-diary/src/delete.rs index 085b79a9..d8ccd47d 100644 --- a/bin/domain/imag-diary/src/delete.rs +++ b/bin/domain/imag-diary/src/delete.rs @@ -19,7 +19,7 @@ use std::process::exit; -use chrono::naive::NaiveDateTime; +use chrono::naive::NaiveDateTime as NDT; use libimagdiary::diaryid::DiaryId; use libimagrt::runtime::Runtime; @@ -44,17 +44,10 @@ pub fn delete(rt: &Runtime) { .value_of("datetime") .map(|dt| { debug!("DateTime = {:?}", dt); dt }) .and_then(DateTime::parse) - .map(|dt| dt.into()) - .ok_or_else(|| { - warn!("Not deleting entries, because missing date/time specification"); - exit(1); - }) - .and_then(|dt: NaiveDateTime| { - DiaryId::from_datetime(diaryname.clone(), dt) - .into_storeid() - .map(|id| rt.store().retrieve(id)) - .map_err_trace_exit_unwrap(1) - }) + .map(Into::into) + .ok_or_else(|| warn_exit("Not deleting entries: missing date/time specification", 1)) + .and_then(|dt: NDT| DiaryId::from_datetime(diaryname.clone(), dt).into_storeid()) + .and_then(|id| rt.store().retrieve(id)) .map_err_trace_exit_unwrap(1) .get_location() .clone(); |