Skip to content

Commit

Permalink
imap-types: impl From<FlagNameAttributeExtension> for `FlagNameAttr…
Browse files Browse the repository at this point in the history
…ibute`

impl `From<FlagNameAttributeExtension>` for `FlagNameAttribute` to
increase API usage ease.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
  • Loading branch information
epilys committed Jan 7, 2025
1 parent e9f22c2 commit f5cba9d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions imap-types/src/flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,12 @@ pub enum FlagNameAttribute<'a> {
Extension(FlagNameAttributeExtension<'a>),
}

impl<'a> From<FlagNameAttributeExtension<'a>> 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)]
Expand Down Expand Up @@ -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));
}
}

0 comments on commit f5cba9d

Please sign in to comment.