Function line_ending

fn line_ending<T, E: ParseError<T>>(input: T) -> crate::internal::IResult<T, T, E>
where
    T: Input + Compare<&'static str>

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

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

Example

# use nom::{Err, error::{Error, ErrorKind}, IResult, Needed};
# use nom::character::complete::line_ending;
fn parser(input: &str) -> IResult<&str, &str> {
    line_ending(input)
}

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))));