Function rocket::mtls::x509::der_parser::asn1_rs::nom::combinator::flat_map
source ยท pub fn flat_map<I, O1, O2, E, F, G, H>(
parser: F,
applied_parser: G,
) -> impl FnMut(I)
Available on crate feature
mtls
only.Expand description
Creates a new parser from the output of the first parser, then apply that parser over the rest of the input.
use nom::bytes::complete::take;
use nom::number::complete::u8;
use nom::combinator::flat_map;
let mut parse = flat_map(u8, take);
assert_eq!(parse(&[2, 0, 1, 2][..]), Ok((&[2][..], &[0, 1][..])));
assert_eq!(parse(&[4, 0, 1, 2][..]), Err(Err::Error((&[0, 1, 2][..], ErrorKind::Eof))));