pub struct Matcher { /* private fields */ }Expand description
The automaton a rule set compiles into.
Implementations§
Source§impl Matcher
impl Matcher
Sourcepub fn build(path: &str, rules: &[Rule]) -> Result<Matcher, Vec<Error>>
pub fn build(path: &str, rules: &[Rule]) -> Result<Matcher, Vec<Error>>
Compile a rule set.
§Errors
A rule whose pattern is one an earlier rule already has can never fire, and that is reported rather than silently dropped. It is always a mistake: either the second rule was meant to say something else, or one of the two should not be there.
Sourcepub fn find<'t>(&self, term: &'t Term) -> Option<Match<'t>>
pub fn find<'t>(&self, term: &'t Term) -> Option<Match<'t>>
Match one term against the whole rule set, returning the rule that fires.
The term is matched as a whole. Finding the subterms of a function worth matching is the selector’s job and not this one’s.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many nodes the trie has, which is what a rule set costs to match against.
Sourcepub fn shape(&self) -> Shape
pub fn shape(&self) -> Shape
What this rule set costs to match against.
The widest node is the measurement that matters, because it is the one the shape of the tree was changed for: it is what a scan would read to the end of and what a search reads eight of. It goes in the header of the generated table, where somebody reviewing a rule they added can see what adding it did.