Function crlf

Source
pub fn crlf<Input, Error>(
    input: &mut Input,
) -> Result<<Input as Stream>::Slice, Error>
where Input: StreamIsPartial + Stream + Compare<&'static str>, Error: ParserError<Input>,
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.

§Effective Signature

Assuming you are parsing a &str Stream:

pub fn crlf<'i>(input: &mut &'i str) -> ModalResult<&'i str>

§Example

fn parser<'s>(input: &mut &'s str) -> ModalResult<&'s str> {
    crlf.parse_next(input)
}

assert_eq!(parser.parse_peek("\r\nc"), Ok(("c", "\r\n")));
assert!(parser.parse_peek("ab\r\nc").is_err());
assert!(parser.parse_peek("").is_err());
assert_eq!(crlf::<_, ErrMode<ContextError>>.parse_peek(Partial::new("\r\nc")), Ok((Partial::new("c"), "\r\n")));
assert!(crlf::<_, ErrMode<ContextError>>.parse_peek(Partial::new("ab\r\nc")).is_err());
assert_eq!(crlf::<_, ErrMode<ContextError>>.parse_peek(Partial::new("")), Err(ErrMode::Incomplete(Needed::Unknown)));