Skip to content

Commit

Permalink
feat: Implement AsRef<str> for AuthMechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
duesee committed Dec 4, 2023
1 parent 937b5cc commit 5da4c1a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imap-types/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ impl<'a> From<Atom<'a>> for AuthMechanism<'a> {

impl<'a> Display for AuthMechanism<'a> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
f.write_str(self.as_ref())
}
}

impl<'a> AsRef<str> for AuthMechanism<'a> {
fn as_ref(&self) -> &str {
match self {
Self::Plain => "PLAIN",
Self::Login => "LOGIN",
Self::XOAuth2 => "XOAUTH2",
Self::Other(other) => other.0.as_ref(),
})
}
}
}

Expand Down

0 comments on commit 5da4c1a

Please sign in to comment.