#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum NSChoice<'a> {
None,
OneOf(&'a str),
AnyOf(&'a [&'a str]),
Any,
}
impl<'a> From<&'a str> for NSChoice<'a> {
fn from(ns: &'a str) -> NSChoice<'a> {
NSChoice::OneOf(ns)
}
}
impl NSChoice<'_> {
pub(crate) fn compare(&self, ns: &str) -> bool {
match (ns, &self) {
(_, NSChoice::None) => false,
(_, NSChoice::Any) => true,
(ns, NSChoice::OneOf(wanted_ns)) => &ns == wanted_ns,
(ns, NSChoice::AnyOf(wanted_nss)) => wanted_nss.iter().any(|w| &ns == w),
}
}
}