pub fn line_ending<T, E>(input: T) -> Result<(T, T), Err<E>>where
    E: ParseError<T>,
    T: Slice<Range<usize>> + Slice<RangeFrom<usize>> + Slice<RangeTo<usize>> + InputIter + InputLength + Compare<&'static str>,
Available on crate feature mtls only.
Expand description

Recognizes an end of line (both ‘\n’ and ‘\r\n’).

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


fn parser(input: &str) -> IResult<&str, &str> {

assert_eq!(parser("\r\nc"), Ok(("c", "\r\n")));
assert_eq!(parser("ab\r\nc"), Err(Err::Error(Error::new("ab\r\nc", ErrorKind::CrLf))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::CrLf))));