Function into

fn into<I, O1, O2, E1, E2, F>(parser: F) -> impl Parser<I, Output = O2, Error = E2>
where
    O2: From<O1>,
    E2: From<E1> + ParseError<I>,
    E1: ParseError<I>,
    F: Parser<I, Output = O1, Error = E1>

automatically converts the child parser's result to another type

it will be able to convert the output value and the error value as long as the Into implementations are available

# use nom::{IResult, Parser};
use nom::combinator::into;
use nom::character::complete::alpha1;
# fn main() {

fn parser1(i: &str) -> IResult<&str, &str> {
  alpha1(i)
}

let mut parser2 = into(parser1);

// the parser converts the &str output of the child parser into a Vec<u8>
let bytes: IResult<&str, Vec<u8>> = parser2.parse("abcd");
assert_eq!(bytes, Ok(("", vec![97, 98, 99, 100])));
# }