use crate::PatternTypes; use crate::errors::PatternError; use crate::parser::parse; use crate::vm::Matcher; use crate::vm::PatternConstants; use crate::vm::MAX_CALLS; pub struct Pattern { consts: PatternConstants, } impl Pattern { pub fn compile(s: &str) -> Result { Ok(Self { consts: parse(s)? }) } pub fn attempt_match<'a, 'b>( &'a self, value: &'b T::Value ) -> Matcher<'a, 'b, T> { Matcher::new(value, &self.consts, self.consts.protos.len() - 1, MAX_CALLS).ok().expect("datafu internal error: MAX_CALLS must not be 0") } }