pub fn crlf<I, E: ParserError<I>>(
input: &mut I,
) -> PResult<<I as Stream>::Slice, E>
Expand description
Recognizes the string "\r\n"
.
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<&'s str, InputError<&'s str>> {
crlf.parse_next(input)
}
assert_eq!(parser.parse_peek("\r\nc"), Ok(("c", "\r\n")));
assert_eq!(parser.parse_peek("ab\r\nc"), Err(ErrMode::Backtrack(InputError::new("ab\r\nc", ErrorKind::Tag))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Tag))));
assert_eq!(crlf::<_, InputError<_>>.parse_peek(Partial::new("\r\nc")), Ok((Partial::new("c"), "\r\n")));
assert_eq!(crlf::<_, InputError<_>>.parse_peek(Partial::new("ab\r\nc")), Err(ErrMode::Backtrack(InputError::new(Partial::new("ab\r\nc"), ErrorKind::Tag))));
assert_eq!(crlf::<_, InputError<_>>.parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::new(2))));