Function winnow::ascii::tab

source ·
pub fn tab<I, Error: ParserError<I>>(input: &mut I) -> PResult<char, Error>
where I: StreamIsPartial + Stream, <I as Stream>::Token: AsChar + Clone,
Expand description

Matches a tab character '\t'.

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

fn parser<'s>(input: &mut &'s str) -> PResult<char, InputError<&'s str>> {
    tab.parse_next(input)
}

assert_eq!(parser.parse_peek("\tc"), Ok(("c", '\t')));
assert_eq!(parser.parse_peek("\r\nc"), Err(ErrMode::Backtrack(InputError::new("\r\nc", ErrorKind::Verify))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Token))));
assert_eq!(tab::<_, InputError<_>>.parse_peek(Partial::new("\tc")), Ok((Partial::new("c"), '\t')));
assert_eq!(tab::<_, InputError<_>>.parse_peek(Partial::new("\r\nc")), Err(ErrMode::Backtrack(InputError::new(Partial::new("\r\nc"), ErrorKind::Verify))));
assert_eq!(tab::<_, InputError<_>>.parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(1))));