refactor: use HashMap::extract_if() stabilized in Rust 1.88.0

This commit is contained in:
link2xt
2025-11-17 13:07:44 +00:00
committed by l
parent 16bd87c78f
commit 72788daca0

View File

@@ -273,12 +273,11 @@ impl MimeMessage {
&mut chat_disposition_notification_to, &mut chat_disposition_notification_to,
&mail, &mail,
); );
headers.retain(|k, _| { headers_removed.extend(
!is_hidden(k) || { headers
headers_removed.insert(k.to_string()); .extract_if(|k, _v| is_hidden(k))
false .map(|(k, _v)| k.to_string()),
} );
});
// Parse hidden headers. // Parse hidden headers.
let mimetype = mail.ctype.mimetype.parse::<Mime>()?; let mimetype = mail.ctype.mimetype.parse::<Mime>()?;
@@ -1680,12 +1679,11 @@ impl MimeMessage {
// See <https://www.rfc-editor.org/rfc/rfc9788.html>. // See <https://www.rfc-editor.org/rfc/rfc9788.html>.
let has_header_protection = part.ctype.params.contains_key("hp"); let has_header_protection = part.ctype.params.contains_key("hp");
headers.retain(|k, _| { headers_removed.extend(
!(has_header_protection || is_protected(k)) || { headers
headers_removed.insert(k.to_string()); .extract_if(|k, _v| has_header_protection || is_protected(k))
false .map(|(k, _v)| k.to_string()),
} );
});
for field in fields { for field in fields {
// lowercasing all headers is technically not correct, but makes things work better // lowercasing all headers is technically not correct, but makes things work better
let key = field.get_key().to_lowercase(); let key = field.get_key().to_lowercase();