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 26 27 28 29
use std::borrow::Cow; use std::ops::Deref; use regex::Regex; pub struct Matcher { path: Cow<'static, str>, regex: Regex } impl Matcher { pub fn new<P: Into<Cow<'static, str>>>(path: P, regex: Regex) -> Matcher { Matcher { path: path.into(), regex: regex } } pub fn path(&self) -> &str { &self.path } } impl Deref for Matcher { type Target = Regex; fn deref(&self) -> &Regex { &self.regex } }