1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use unicase::UniCase;

#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum CaseSensitivity {
    Insensitive(UniCase<String>),
    Sensitive(String),
}

impl AsRef<str> for CaseSensitivity {
    fn as_ref(&self) -> &str {
        match self {
            Self::Insensitive(u) => u.as_str(),
            Self::Sensitive(s) => s.as_str(),
        }
    }
}

impl PartialEq<str> for CaseSensitivity {
    fn eq(&self, other: &str) -> bool {
        match self {
            Self::Insensitive(u) => u == &UniCase::new(other),
            Self::Sensitive(s) => s == other,
        }
    }
}