From 3fa9e355c2a1017189733f47e7baaf129e6dd905 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Sun, 10 Jan 2021 13:20:05 +0200 Subject: [PATCH] melib/email: add Flag is_*() methods --- melib/src/email.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/melib/src/email.rs b/melib/src/email.rs index a333b736..07df8531 100644 --- a/melib/src/email.rs +++ b/melib/src/email.rs @@ -143,6 +143,23 @@ impl PartialEq<&str> for Flag { } } +macro_rules! flag_impl { + (fn $name:ident, $val:expr) => { + pub const fn $name(&self) -> bool { + self.contains($val) + } + }; +} + +impl Flag { + flag_impl!(fn is_seen, Flag::SEEN); + flag_impl!(fn is_draft, Flag::DRAFT); + flag_impl!(fn is_trashed, Flag::TRASHED); + flag_impl!(fn is_passed, Flag::PASSED); + flag_impl!(fn is_replied, Flag::REPLIED); + flag_impl!(fn is_flagged, Flag::FLAGGED); +} + ///`Mail` holds both the envelope info of an email in its `envelope` field and the raw bytes that ///describe the email in `bytes`. Its body as an `melib::email::Attachment` can be parsed on demand ///with the `melib::email::Mail::body` method.