Function nom::combinator::map_parser [−][src]
pub fn map_parser<I: Clone, O1, O2, E: ParseError<I>, F, G>(
first: F,
second: G
) -> impl Fn(I) -> IResult<I, O2, E> where
F: Fn(I) -> IResult<I, O1, E>,
G: Fn(O1) -> IResult<O1, O2, E>,
O1: InputLength,
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 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))));