Function winnow::combinator::not

source ·
pub fn not<Input, Output, Error, ParseNext>(
    parser: ParseNext
) -> impl Parser<Input, (), Error>
where Input: Stream, Error: ParserError<Input>, ParseNext: Parser<Input, Output, Error>,
Expand description

Succeeds if the child parser returns an error.

Note: This does not advance the Stream

§Example

use winnow::combinator::not;
use winnow::ascii::alpha1;

let mut parser = not(alpha1);

assert_eq!(parser.parse_peek("123"), Ok(("123", ())));
assert_eq!(parser.parse_peek("abcd"), Err(ErrMode::Backtrack(InputError::new("abcd", ErrorKind::Not))));