pub fn tab<Input, Error>(input: &mut Input) -> PResult<char, Error>
Expand description
Matches a tab character '\t'
.
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 tab(input: &mut &str) -> PResult<char>
§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::Tag))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Tag))));
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::Tag))));
assert_eq!(tab::<_, InputError<_>>.parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(1))));