pub fn map_parser<I, O1, O2, E, F, G>(
parser: F,
applied_parser: G,
) -> impl FnMut(I)
Available on crate feature
mtls
only.Expand description
Applies a parser over the result of another one.
use nom::character::complete::digit1;
use nom::bytes::complete::take;
use nom::combinator::map_parser;
let mut parse = map_parser(take(5u8), digit1);
assert_eq!(parse("12345"), Ok(("", "12345")));
assert_eq!(parse("123ab"), Ok(("", "123")));
assert_eq!(parse("123"), Err(Err::Error(("123", ErrorKind::Eof))));