Function winnow::token::any

source ·
pub fn any<Input, Error>(
    input: &mut Input,
) -> PResult<<Input as Stream>::Token, Error>
where Input: StreamIsPartial + Stream, Error: ParserError<Input>,
Expand description

Matches one token

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

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

§Effective Signature

Assuming you are parsing a &str Stream:

pub fn any(input: &mut &str) -> PResult<char>

§Example

fn parser(input: &str) -> IResult<&str, char> {
    any.parse_peek(input)
}

assert_eq!(parser("abc"), Ok(("bc",'a')));
assert_eq!(parser(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Token))));
assert_eq!(any::<_, InputError<_>>.parse_peek(Partial::new("abc")), Ok((Partial::new("bc"),'a')));
assert_eq!(any::<_, InputError<_>>.parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(1))));