rocket::mtls::oid::asn1_rs::nom::combinator

Function recognize

Source
pub fn recognize<I, O, E, F>(parser: F) -> impl FnMut(I)
where I: Clone + Offset + Slice<RangeTo<usize>>, E: ParseError<I>, F: Parser<I, O, E>,
Available on crate feature mtls only.
Expand description

If the child parser was successful, return the consumed input as produced value.

use nom::combinator::recognize;
use nom::character::complete::{char, alpha1};
use nom::sequence::separated_pair;

let mut parser = recognize(separated_pair(alpha1, char(','), alpha1));

assert_eq!(parser("abcd,efgh"), Ok(("", "abcd,efgh")));
assert_eq!(parser("abcd;"),Err(Err::Error((";", ErrorKind::Char))));