rocket::mtls::oid::asn1_rs::nom::character::streaming

Function 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

Streaming version: Will return Err(nom::Err::Incomplete(_)) 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::Incomplete(Needed::Unknown)));