more functional

This commit is contained in:
Hocuri
2020-06-12 11:11:24 +02:00
parent 27ff1c4a75
commit 1fe85dfb3c

View File

@@ -910,18 +910,18 @@ impl MimeMessage {
.to_ascii_lowercase() .to_ascii_lowercase()
.contains("daemon") .contains("daemon")
&& self.failure_report.is_none() && self.failure_report.is_none()
{
for line in self
.parts
.iter()
.filter_map(|p| p.msg_raw.as_ref())
.flat_map(|p| p.lines())
{ {
lazy_static! { lazy_static! {
static ref RE: regex::Regex = regex::Regex::new(r"Message-ID:(.*)").unwrap(); static ref RE: regex::Regex = regex::Regex::new(r"Message-ID:(.*)").unwrap();
} }
if let Some(c) = RE.captures(line) { for captures in self
if let Ok(original_message_id) = parse_message_id(&c[1]) { .parts
.iter()
.filter_map(|part| part.msg_raw.as_ref())
.flat_map(|part| part.lines())
.filter_map(|line| RE.captures(line))
{
if let Ok(original_message_id) = parse_message_id(&captures[1]) {
if let Ok(Some(_)) = if let Ok(Some(_)) =
message::rfc724_mid_exists(context, &original_message_id).await message::rfc724_mid_exists(context, &original_message_id).await
{ {
@@ -933,7 +933,6 @@ impl MimeMessage {
} }
} }
} }
}
None // Always return None, we just return anything so that we can use the '?' operator. None // Always return None, we just return anything so that we can use the '?' operator.
} }