From f5cba9d791d7d27fe6eb8a4b4bafb5d1362e6b5f Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 6 Jan 2025 17:43:54 +0200 Subject: [PATCH] imap-types: impl `From` for `FlagNameAttribute` impl `From` for `FlagNameAttribute` to increase API usage ease. Signed-off-by: Manos Pitsidianakis --- imap-types/src/flag.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/imap-types/src/flag.rs b/imap-types/src/flag.rs index 504c4f99..14bbf69d 100644 --- a/imap-types/src/flag.rs +++ b/imap-types/src/flag.rs @@ -154,6 +154,12 @@ pub enum FlagNameAttribute<'a> { Extension(FlagNameAttributeExtension<'a>), } +impl<'a> From> for FlagNameAttribute<'a> { + fn from(extension: FlagNameAttributeExtension<'a>) -> Self { + Self::Extension(extension) + } +} + /// An extension flag. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[derive(Debug, Clone, PartialEq, Eq, Hash, ToStatic)] @@ -226,4 +232,11 @@ mod tests { let flag_perm: FlagPerm<'static> = flag.into(); assert_eq!(flag_perm, FlagPerm::Flag(Flag::Seen)); } + + #[test] + fn test_flagnameattribute() { + let atom = FlagNameAttributeExtension(Atom::try_from("Custom").unwrap()); + let flag_name_attribute = FlagNameAttribute::from(atom.clone()); + assert_eq!(flag_name_attribute, FlagNameAttribute::Extension(atom)); + } }