Macro gramma::string_matcher

source ·
macro_rules! string_matcher {
    ($expr:expr $(,)?) => { ... };
}
Expand description

Creates a StringMatcher from the given StringPattern. Approximately a shorthand for &string_pattern!(pattern).matcher().

Matchers are self-referential, so the output can’t be moved after it’s created. All predefined patterns in the patterns module are brought into scope for the pattern expression.

§Example

let quotes_matcher = gramma::string_matcher!(
    char('"') + char(..).repeat(..).lazy() + !follows(char('\\')) + char('"')
);

assert!(quotes_matcher.match_string(4, r#"s = "hello, \"world\"!";"#).is_some());