Skip to content

Commit

Permalink
imap-types: impl From<Flag> for FlagPerm
Browse files Browse the repository at this point in the history
impl `From<Flag>` for `FlagPerm` to increase API usage ease.

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
  • Loading branch information
epilys committed Jan 7, 2025
1 parent e16c343 commit e9f22c2
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 @@ -123,6 +123,12 @@ pub enum FlagPerm<'a> {
Asterisk,
}

impl<'a> From<Flag<'a>> for FlagPerm<'a> {
fn from(flag: Flag<'a>) -> Self {
Self::Flag(flag)
}
}

/// Four name attributes are defined.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Eq, Hash, ToStatic)]
Expand Down Expand Up @@ -213,4 +219,11 @@ mod tests {
let flag_fetch: FlagFetch<'static> = flag.into();
assert_eq!(flag_fetch, FlagFetch::Flag(Flag::Seen));
}

#[test]
fn test_flagperm() {
let flag: Flag<'static> = Flag::Seen;
let flag_perm: FlagPerm<'static> = flag.into();
assert_eq!(flag_perm, FlagPerm::Flag(Flag::Seen));
}
}

0 comments on commit e9f22c2

Please sign in to comment.