use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Matcher {
Text {
case_sensitive: bool,
anchor_start: bool,
text: String,
anchor_end: bool,
},
Regex(Regex),
Any { explicit: bool },
}
#[derive(Debug, Clone)]
pub struct Regex {
pub(crate) re: fancy_regex::Regex,
}
impl PartialEq for Regex {
fn eq(&self, other: &Self) -> bool {
self.re.as_str() == other.re.as_str()
}
}
impl Eq for Regex {}
impl PartialOrd for Regex {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Regex {
fn cmp(&self, other: &Self) -> Ordering {
Ord::cmp(self.re.as_str(), other.re.as_str())
}
}
impl Hash for Regex {
fn hash<H: Hasher>(&self, state: &mut H) {
Hash::hash(self.re.as_str(), state);
}
}