Function rocket::mtls::x509::der_parser::asn1_rs::nom::character::complete::satisfy

source ·
pub fn satisfy<F, I, Error>(cond: F) -> impl Fn(I)
where Error: ParseError<I>, I: Slice<RangeFrom<usize>> + InputIter, <I as InputIter>::Item: AsChar, F: Fn(char) -> bool,
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))));