diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-11-10 02:03:54 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-12-22 02:03:35 +0100 |
commit | 4c95345dc0feebc14e3ed9e4cc2c0d36ce44dd8a (patch) | |
tree | 50390c77e1dfa05999726295e00632b1177152dc | |
parent | eb70efe59ecac2c158cea58ca8abb5f1ae26a3f5 (diff) |
Rewrite closure for more structured and easy-to-read code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/domain/imag-calendar/src/util.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/bin/domain/imag-calendar/src/util.rs b/bin/domain/imag-calendar/src/util.rs index 416404ab..2e9c831a 100644 --- a/bin/domain/imag-calendar/src/util.rs +++ b/bin/domain/imag-calendar/src/util.rs @@ -163,18 +163,20 @@ pub fn find_event_by_id<'a>(store: &'a Store, id: &str, refconfig: &Config) -> R if parsed .get_data() .events() - .filter(|event| if event - .as_ref() - .map(|e| { - trace!("Checking whether {:?} starts with {}", e.uid(), id); - e.uid().map(|uid| uid.raw().starts_with(id)).unwrap_or(false) - }) - .unwrap_or(false) - { - trace!("Seems to be relevant"); - true - } else { - false + .filter(|event| { + let take = event + .as_ref() + .map(|e| { + trace!("Checking whether {:?} starts with {}", e.uid(), id); + e.uid().map(|uid| uid.raw().starts_with(id)).unwrap_or(false) + }) + .unwrap_or(false); + + if take { + trace!("Seems to be relevant"); + } + + take }) .next() .is_some() |