pub fn char<I, Error>(c: char) -> impl Fn(I)where
Error: ParseError<I>,
I: Slice<RangeFrom<usize>> + InputIter + InputLength,
<I as InputIter>::Item: AsChar,
Available on crate feature
mtls
only.Expand description
Recognizes one character.
Streaming version: Will return Err(nom::Err::Incomplete(_))
if there’s not enough input data.
§Example
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))));