pub fn satisfy<F, I, Error>(cond: F) -> impl Fn(I)
Available on crate feature
mtls
only.Expand description
Recognizes one character and checks that it satisfies a predicate
Complete version: Will return an error if there’s not enough input data.
§Example
fn parser(i: &str) -> IResult<&str, char> {
satisfy(|c| c == 'a' || c == 'b')(i)
}
assert_eq!(parser("abc"), Ok(("bc", 'a')));
assert_eq!(parser("cd"), Err(Err::Error(Error::new("cd", ErrorKind::Satisfy))));
assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Satisfy))));