Function winnow::token::none_of

source ·
pub fn none_of<I, T, Error: ParserError<I>>(
    list: T,
) -> impl Parser<I, <I as Stream>::Token, Error>
where I: StreamIsPartial + Stream, <I as Stream>::Token: Clone, T: ContainsToken<<I as Stream>::Token>,
Expand description

Recognize a token that does not match the pattern

Complete version: Will return an error if there’s not enough input data.

Partial version: Will return Err(winnow::error::ErrMode::Incomplete(_)) if there’s not enough input data.

§Example

assert_eq!(none_of::<_, _, InputError<_>>(['a', 'b', 'c']).parse_peek("z"), Ok(("", 'z')));
assert_eq!(none_of::<_, _, InputError<_>>(['a', 'b']).parse_peek("a"), Err(ErrMode::Backtrack(InputError::new("a", ErrorKind::Verify))));
assert_eq!(none_of::<_, _, InputError<_>>('a').parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Token))));
assert_eq!(none_of::<_, _, InputError<_>>(['a', 'b', 'c']).parse_peek(Partial::new("z")), Ok((Partial::new(""), 'z')));
assert_eq!(none_of::<_, _, InputError<_>>(['a', 'b']).parse_peek(Partial::new("a")), Err(ErrMode::Backtrack(InputError::new(Partial::new("a"), ErrorKind::Verify))));
assert_eq!(none_of::<_, _, InputError<_>>('a').parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(1))));