#[cfg(feature = "regex")]
use regex_lite::Regex;
#[cfg(feature = "regex")]
use super::PatternMatcher;
#[cfg(feature = "regex")]
pub(crate) struct RegexMatcher(Regex);
#[cfg(feature = "regex")]
impl RegexMatcher {
pub(crate) fn new(pattern: &str) -> Result<Self, String> {
Regex::new(pattern)
.map(RegexMatcher)
.map_err(|e| e.to_string())
}
}
#[cfg(feature = "regex")]
impl PatternMatcher for RegexMatcher {
fn matches(&self, target: &str) -> bool {
self.0.is_match(target)
}
}