Function char

fn char<I, Error: ParseError<I>>(c: char) -> impl FnMut(I) -> crate::internal::IResult<I, char, Error>
where
    I: Input,
    <I as Input>::Item: AsChar

Recognizes one character.

Streaming version: Will return Err(nom::Err::Incomplete(_)) if there's not enough input data.

Example

# use nom::{Err, error::{ErrorKind, Error}, Needed, IResult};
# use nom::character::streaming::char;
fn parser(i: &str) -> IResult<&str, char> {
    char('a')(i)
}
assert_eq!(parser("abc"), Ok(("bc", 'a')));
assert_eq!(parser("bc"), Err(Err::Error(Error::new("bc", ErrorKind::Char))));
assert_eq!(parser(""), Err(Err::Incomplete(Needed::new(1))));