pub fn not_line_ending<T, E: ParseError<T>, const STREAMING: bool>(
    input: T
) -> IResult<T, <T as IntoOutput>::Output, E>where
    T: Slice<Range<usize>> + Slice<RangeFrom<usize>> + Slice<RangeTo<usize>> + InputIter + InputLength + InputIsStreaming<STREAMING> + IntoOutput + Compare<&'static str>,
    <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.

Streaming version: Will return Err(nom8::Err::Incomplete(_)) 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 })));
assert_eq!(not_line_ending::<_, (_, ErrorKind), true>(Streaming("ab\r\nc")), Ok((Streaming("\r\nc"), "ab")));
assert_eq!(not_line_ending::<_, (_, ErrorKind), true>(Streaming("abc")), Err(Err::Incomplete(Needed::Unknown)));
assert_eq!(not_line_ending::<_, (_, ErrorKind), true>(Streaming("")), Err(Err::Incomplete(Needed::Unknown)));
assert_eq!(not_line_ending::<_, (_, ErrorKind), true>(Streaming("a\rb\nc")), Err(Err::Error((Streaming("a\rb\nc"), ErrorKind::Tag ))));
assert_eq!(not_line_ending::<_, (_, ErrorKind), true>(Streaming("a\rbc")), Err(Err::Error((Streaming("a\rbc"), ErrorKind::Tag ))));