Function nom8::combinator::map_parser

source ·
pub fn map_parser<I, O1, O2, E: ParseError<I>, F, G>(
    parser: F,
    applied_parser: G
) -> impl FnMut(I) -> IResult<I, O2, E>where
    F: Parser<I, O1, E>,
    G: Parser<O1, O2, E>,
👎Deprecated since 8.0.0: Replaced with `Parser::and_then
Expand description

Applies a parser over the result of another one.

WARNING: Deprecated, replaced with Parser::and_then

use nom8::character::digit1;
use nom8::bytes::take;
use nom8::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))));