Function nom8::combinator::flat_map

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

Creates a new parser from the output of the first parser, then apply that parser over the rest of the input.

WARNING: Deprecated, replaced with Parser::flat_map

use nom8::bytes::take;
use nom8::number::u8;
use nom8::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))));