Function nom8::combinator::map
source · pub fn map<I, O1, O2, E, F, G>(
parser: F,
f: G
) -> impl FnMut(I) -> IResult<I, O2, E>where
F: Parser<I, O1, E>,
G: FnMut(O1) -> O2,
👎Deprecated since 8.0.0: Replaced with `Parser::map
Expand description
Maps a function on the result of a parser.
WARNING: Deprecated, replaced with Parser::map
use nom8::{Err,error::ErrorKind, IResult,Parser};
use nom8::character::digit1;
use nom8::combinator::map;
let mut parser = map(digit1, |s: &str| s.len());
// the parser will count how many characters were returned by digit1
assert_eq!(parser.parse("123456"), Ok(("", 6)));
// this will fail if digit1 fails
assert_eq!(parser.parse("abc"), Err(Err::Error(("abc", ErrorKind::Digit))));