melib: add Envelope::recipient_any method

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
This commit is contained in:
Manos Pitsidianakis 2024-05-08 20:42:29 +03:00
parent 735b44f286
commit 1abce964c7
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

View File

@ -859,6 +859,16 @@ impl Envelope {
pub fn tags_mut(&mut self) -> &mut IndexSet<TagHash> { pub fn tags_mut(&mut self) -> &mut IndexSet<TagHash> {
&mut self.tags &mut self.tags
} }
/// Returns `true` if `is_recipient` address is included in To:, Cc: or Bcc:
/// headers.
pub fn recipient_any(&self, is_recipient: &Address) -> bool {
self.to()
.iter()
.chain(self.cc().iter())
.chain(self.bcc().iter())
.any(|a| a == is_recipient)
}
} }
impl Eq for Envelope {} impl Eq for Envelope {}