Function fail

Source
pub fn fail<Input, Output, Error>(i: &mut Input) -> Result<Output, Error>
where Input: Stream, Error: ParserError<Input>,
Expand description

A parser which always fails.

For example, it can be used as the last alternative in alt to control the error message given.

§Example

use winnow::combinator::fail;

fn parser<'i>(input: &mut &'i str) -> ModalResult<(), InputError<&'i str>> {
    fail.parse_next(input)
}

assert_eq!(parser.parse_peek("string"), Err(ErrMode::Backtrack(InputError::at("string"))));