Skip to main content

MatchParser

Trait MatchParser 

Source
pub trait MatchParser: Send + Sync {
    // Required method
    fn find(&self, text: &str, offset: usize) -> Result<Vec<RawMatch>, String>;
}
Expand description

A custom matcher: finds every hit for a rule in one scan unit (the whole file for global rules, a scope region for scoped rules).

This is the escape hatch beyond regexes — with the whole text in hand, a parser can count duplicates, flag absent constructs, or hand-roll any matching logic. Must be pure: same (text, offset), same matches.

Required Methods§

Source

fn find(&self, text: &str, offset: usize) -> Result<Vec<RawMatch>, String>

Finds all matches. An Err surfaces as an error-severity diagnostic naming the rule — the lint run itself is never affected.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§