From 08c77c2668e25adb2c3a6465fd9aa5423a39f2ed Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Sun, 16 Feb 2020 04:10:35 +0300 Subject: [PATCH] fetch_single_msg: use if let Some(...) instead of is_empty() --- src/imap/mod.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/imap/mod.rs b/src/imap/mod.rs index 626a92feb..4c157661d 100644 --- a/src/imap/mod.rs +++ b/src/imap/mod.rs @@ -755,16 +755,7 @@ impl Imap { return Err(Error::Other("Could not get IMAP session".to_string())); }; - if msgs.is_empty() { - warn!( - context, - "Message #{} does not exist in folder \"{}\".", - server_uid, - folder.as_ref() - ); - } else { - let msg = &msgs[0]; - + if let Some(msg) = msgs.first() { // XXX put flags into a set and pass them to dc_receive_imf let is_deleted = msg.flags().any(|flag| match flag { Flag::Deleted => true, @@ -789,6 +780,13 @@ impl Imap { ); } } + } else { + warn!( + context, + "Message #{} does not exist in folder \"{}\".", + server_uid, + folder.as_ref() + ); } Ok(())