diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-06-04 11:41:31 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-06-04 11:57:06 +0200 |
commit | 939a31ad2b3cb18074b51a1659b1f79f9cd6bd3b (patch) | |
tree | 75c0b844345ca9507389e6b07a926f55df8e5ee5 | |
parent | 7a085aae18f1f6d5ca5f3344f3a69754c8513ad2 (diff) |
Collapse nested if-else
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/domain/imag-mail/src/lib.rs | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/bin/domain/imag-mail/src/lib.rs b/bin/domain/imag-mail/src/lib.rs index 701a8070..e3cf099a 100644 --- a/bin/domain/imag-mail/src/lib.rs +++ b/bin/domain/imag-mail/src/lib.rs @@ -195,37 +195,35 @@ fn list(rt: &Runtime) -> Result<()> { .map(Ok); process(iter, &mut i, ¬much_connection, &list_format, rt, &mut out) + } else if scmd.is_present("query-from-stdin") { + let stdin = ::std::io::stdin(); + + let mailstore = store.with_connection(¬much_connection); + stdin.lock() + .lines() + .map(|r| r.map_err(Error::from).and_then(|query| { + debug!("Querying: {}", query); + let it = mailstore.query(&query)?; + + debug!("Found: {:?}", it); + let it = it.into_iter().map(Ok); + + process(it, &mut i, ¬much_connection, &list_format, rt, &mut out) + })) + .collect::<Result<_>>() } else { - if scmd.is_present("query-from-stdin") { - let stdin = ::std::io::stdin(); - - let mailstore = store.with_connection(¬much_connection); - stdin.lock() - .lines() - .map(|r| r.map_err(Error::from).and_then(|query| { - debug!("Querying: {}", query); - let it = mailstore.query(&query)?; - - debug!("Found: {:?}", it); - let it = it.into_iter().map(Ok); - - process(it, &mut i, ¬much_connection, &list_format, rt, &mut out) - })) - .collect::<Result<_>>() - } else { - // use StoreIds to find mails - let iter = rt.ids::<crate::ui::PathProvider>()? - .ok_or_else(|| anyhow!("No ids supplied"))? - .into_iter() - .map(Ok) - .into_get_iter(rt.store()) - .map_inner_ok_or_else(|| anyhow!("Did not find one entry")) - .and_then_ok(|m| m.is_mail().map(|b| (b, m))) - .filter_ok(|tpl| tpl.0) - .map_ok(|tpl| tpl.1); - - process(iter, &mut i, ¬much_connection, &list_format, rt, &mut out) - } + // use StoreIds to find mails + let iter = rt.ids::<crate::ui::PathProvider>()? + .ok_or_else(|| anyhow!("No ids supplied"))? + .into_iter() + .map(Ok) + .into_get_iter(rt.store()) + .map_inner_ok_or_else(|| anyhow!("Did not find one entry")) + .and_then_ok(|m| m.is_mail().map(|b| (b, m))) + .filter_ok(|tpl| tpl.0) + .map_ok(|tpl| tpl.1); + + process(iter, &mut i, ¬much_connection, &list_format, rt, &mut out) } } |