Macro nom::fix_error
[−]
[src]
macro_rules! fix_error { ($i:expr, $t:ty, $submac:ident!( $($args:tt)* )) => { ... }; ($i:expr, $t:ty, $f:expr) => { ... }; }
translate parser result from IResult to IResult with a custom type
// will add a Custom(42) error to the error chain
named!(err_test, add_return_error!(ErrorKind::Custom(42), tag!("abcd")));
// Convert to IREsult<&[u8], &[u8], &str>
named!(parser<&[u8], &[u8], &str>, add_return_error!(ErrorKind::Custom("custom error message"), fix_error!(&str, err_test)));
let a = &b"efghblah"[..];
let res_a = parser(a);
assert_eq!(res_a, Error(error_node_position!( ErrorKind::Custom("custom error message"), a, Position(ErrorKind::Fix, a))));