summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-06-04 11:41:31 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-06-04 11:57:06 +0200
commit939a31ad2b3cb18074b51a1659b1f79f9cd6bd3b (patch)
tree75c0b844345ca9507389e6b07a926f55df8e5ee5
parent7a085aae18f1f6d5ca5f3344f3a69754c8513ad2 (diff)
Collapse nested if-else
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-mail/src/lib.rs58
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, &notmuch_connection, &list_format, rt, &mut out)
+ } else if scmd.is_present("query-from-stdin") {
+ let stdin = ::std::io::stdin();
+
+ let mailstore = store.with_connection(&notmuch_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, &notmuch_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(&notmuch_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, &notmuch_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, &notmuch_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, &notmuch_connection, &list_format, rt, &mut out)
}
}