Function rocket::mtls::oid::asn1_rs::nom::bytes::streaming::is_a

source ·
pub fn is_a<T, Input, Error>(arr: T) -> impl Fn(Input)
where Error: ParseError<Input>, Input: InputTakeAtPosition, T: FindToken<<Input as InputTakeAtPosition>::Item>,
Available on crate feature mtls only.
Expand description

Returns the longest slice of the matches the pattern.

The parser will return the longest slice consisting of the characters in provided in the combinator’s argument.

§Streaming specific

Streaming version will return a Err::Incomplete(Needed::new(1)) if the pattern wasn’t met or if the pattern reaches the end of the input.


use nom::bytes::streaming::is_a;

fn hex(s: &str) -> IResult<&str, &str> {

assert_eq!(hex("123 and voila"), Ok((" and voila", "123")));
assert_eq!(hex("DEADBEEF and others"), Ok((" and others", "DEADBEEF")));
assert_eq!(hex("BADBABEsomething"), Ok(("something", "BADBABE")));
assert_eq!(hex("D15EA5E"), Err(Err::Incomplete(Needed::new(1))));
assert_eq!(hex(""), Err(Err::Incomplete(Needed::new(1))));