Make has_str input generic

This commit is contained in:
avitex 2019-09-02 23:02:51 +10:00
parent ff8e638591
commit 1c348a4ffa
No known key found for this signature in database
GPG key ID: 38C76CBF3749D62C

View file

@ -38,12 +38,13 @@ pub struct Capabilities(
impl Capabilities {
/// Check if the server has the given capability.
pub fn has<'a>(&self, s: &Capability<'a>) -> bool {
self.0.contains(s)
pub fn has<'a>(&self, cap: &Capability<'a>) -> bool {
self.0.contains(cap)
}
/// Check if the server has the given capability via str.
pub fn has_str(&self, s: &str) -> bool {
pub fn has_str<S: AsRef<str>>(&self, cap: S) -> bool {
let s = cap.as_ref();
if s == IMAP4REV1_CAPABILITY {
self.has(&Capability::Imap4rev1)
} else if s.starts_with(AUTH_CAPABILITY_PREFIX) {