[][src]Function nom::character::complete::newline

pub fn newline<I, Error: ParseError<I>>(input: I) -> IResult<I, char, Error> where
    I: Slice<RangeFrom<usize>> + InputIter,
    <I as InputIter>::Item: AsChar

Matches a newline character '\n'.

complete version: Will return an error 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(("\r\nc", ErrorKind::Char))));
assert_eq!(parser(""), Err(Err::Error(("", ErrorKind::Char))));