Function nom8::combinator::into
source · pub fn into<I, O1, O2, E1, E2, F>(
parser: F
) -> impl FnMut(I) -> IResult<I, O2, E2>where
O1: Into<O2>,
E1: Into<E2> + ParseError<I>,
E2: ParseError<I>,
F: Parser<I, O1, E1>,
👎Deprecated since 8.0.0: Replaced with
Parser::output_into
and Parser::err_into
Expand description
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
WARNING: Deprecated, replaced with Parser::output_into
and Parser::err_into
use nom8::combinator::into;
use nom8::character::alpha1;
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("abcd");
assert_eq!(bytes, Ok(("", vec![97, 98, 99, 100])));