Function combine::unexpected

source ·
pub fn unexpected<Input, S>(message: S) -> Unexpected<Input, (), S>
where Input: Stream, S: for<'s> ErrorInfo<'s, Input::Token, Input::Range>,
Expand description

Always fails with message as an unexpected error. Never consumes any input.

Has () the output type

let result = unexpected("token")
    .easy_parse("a");
assert!(result.is_err());
assert!(
    result.err()
        .unwrap()
        .errors
        .iter()
        .any(|m| *m == StreamError::unexpected("token"))
);