Function chumsky::primitive::one_of

source ·
pub fn one_of<I, C: Container<I>, E: Error<I>>(inputs: C) -> OneOf<I, C, E>
Expand description

A parser that accepts one of a sequence of specific inputs.

The output type of this parser is I, the input that was found.

Examples

let digits = one_of::<_, _, Cheap<char>>("0123456789")
    .repeated().at_least(1)
    .then_ignore(end())
    .collect::<String>();

assert_eq!(digits.parse("48791"), Ok("48791".to_string()));
assert!(digits.parse("421!53").is_err());