pub fn char<I, Error: ParseError<I>>(
c: char
) -> impl Fn(I) -> IResult<I, char, Error>where
I: Stream,
<I as Stream>::Token: AsChar,👎Deprecated since 0.1.0: Replaced with <code>winnow::bytes::one_of</code>
Expand description
Recognizes one character.
Complete version: Will return an error 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(" abc"), Err(ErrMode::Backtrack(Error::new(" abc", ErrorKind::Char))));
assert_eq!(parser("bc"), Err(ErrMode::Backtrack(Error::new("bc", ErrorKind::Char))));
assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Char))));WARNING: Deprecated, replaced with winnow::bytes::one_of