pub fn newline<I, Error: ParseError<I>, const STREAMING: bool>(
input: I
) -> IResult<I, char, Error>where
I: Slice<RangeFrom<usize>> + InputIter + InputLength + InputIsStreaming<STREAMING>,
<I as InputIter>::Item: AsChar,
Expand description
Matches a newline character ‘\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, char> {
newline(input)
}
assert_eq!(parser("\nc"), Ok(("c", '\n')));
assert_eq!(parser("\r\nc"), Err(Err::Error(Error::new("\r\nc", ErrorKind::Char))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Char))));
assert_eq!(newline::<_, (_, ErrorKind), true>(Streaming("\nc")), Ok((Streaming("c"), '\n')));
assert_eq!(newline::<_, (_, ErrorKind), true>(Streaming("\r\nc")), Err(Err::Error((Streaming("\r\nc"), ErrorKind::Char))));
assert_eq!(newline::<_, (_, ErrorKind), true>(Streaming("")), Err(Err::Incomplete(Needed::new(1))));