Function any_of_m

Source
pub fn any_of_m<M, V>(marker: M, tokens: V) -> Token
where M: Hash, V: Into<Vec<Token>>,
Expand description

A variant of any_of with a marker assigned, making it easy to jump directly to the matched result within the token tree.

ยงExamples

use initiative_core::command::prelude::*;

#[derive(Hash)]
enum Marker {
    AnyOf,
}

let query = "badger snake";
let token = sequence([
    keyword("badger"),
    any_of_m(Marker::AnyOf, [keyword("mushroom"), keyword("snake")]),
]);
let token_match = token.match_input_exact(query, &app_meta).next().await.unwrap();

assert_eq!(
    Some(&[TokenMatch::from(&keyword("snake"))][..]),
    token_match.find_marker(Marker::AnyOf).unwrap().meta_sequence(),
);