# Function nom::character::complete::not_line_ending

source · [−]

    pub fn not_line_ending<T, E: ParseError<T>>(input: T) -> IResult<T, T, E> where
        T: Slice<Range<usize>> + Slice<RangeFrom<usize>> + Slice<RangeTo<usize>>,
        T: InputIter + InputLength,
        T: Compare<&'static str>,
        <T as InputIter>::Item: AsChar,
        <T as InputIter>::Item: AsChar,

Expand description

Recognizes a string of any char except ‘\r\n’ or ‘\n’.

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

## Example

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

    assert_eq!(parser("ab\r\nc"), Ok(("\r\nc", "ab")));
    assert_eq!(parser("ab\nc"), Ok(("\nc", "ab")));
    assert_eq!(parser("abc"), Ok(("", "abc")));
    assert_eq!(parser(""), Ok(("", "")));
    assert_eq!(parser("a\rb\nc"), Err(Err::Error(Error { input: "a\rb\nc", code: ErrorKind::Tag })));
    assert_eq!(parser("a\rbc"), Err(Err::Error(Error { input: "a\rbc", code: ErrorKind::Tag })));