fn map_err<'a, O, Parser, ErrorMapper, InitialError>(
    mut parser: Parser,
    mut f: ErrorMapper,
) -> impl FnMut(&'a str) -> IResult<&'a str, O, PassportParseErrorExact>
where
    Parser: FnMut(&'a str) -> IResult<&'a str, O, InitialError>,
    ErrorMapper: FnMut(InitialError) -> PassportParseErrorExact<'a>,
{
    move |input: &'a str| {
        parser(input).map_err(|e| match e {
            nom::Err::Error(e2) => nom::Err::Error(f(e2)),
            nom::Err::Failure(e2) => nom::Err::Failure(f(e2)),
            nom::Err::Incomplete(_) => {
                unreachable!("Parser should never generate Incomplete errors")
            }
        })
    }
}
/// Wraps a parser and replaces its error by calling the given 'f' function.
/// nom provides map_res which is similar to Result::and_then,
/// but doesn't provide a map_err similar to Result::map_err.
Wraps a parser and replaces its error by calling the given 'f' function.
nom provides map_res which is similar to Result::and_then,
but doesn't provide a map_err similar to Result::map_err.
Wraps a parser and replaces its error by calling the given ' f ' function . nom provides map_res which is similar to Result :: and_then but doesn ' t provide a map_err similar to Result :: map_err .
fn map_err<'a, O, Parser, ErrorMapper, InitialError>(
    mut parser: Parser,
    mut f: ErrorMapper,
) -> impl FnMut(&'a str) -> IResult<&'a str, O, PassportParseErrorExact>
where
    Parser: FnMut(&'a str) -> IResult<&'a str, O, InitialError>,
    ErrorMapper: FnMut(InitialError) -> PassportParseErrorExact<'a>,
{
    move |input: &'a str| {
        parser(input).map_err(|e| match e {
            nom::Err::Error(e2) => nom::Err::Error(f(e2)),
            nom::Err::Failure(e2) => nom::Err::Failure(f(e2)),
            nom::Err::Incomplete(_) => {
                unreachable!("Parser should never generate Incomplete errors")
            }
        })
    }
}
fn map_err < ' a , O , Parser , ErrorMapper , InitialError > ( mut parser : Parser , mut f : ErrorMapper , ) -> impl FnMut ( & ' a str ) -> IResult < & ' a str , O , PassportParseErrorExact > where Parser : FnMut ( & ' a str ) -> IResult < & ' a str , O , InitialError > , ErrorMapper : FnMut ( InitialError ) -> PassportParseErrorExact < ' a > , { move | input : & ' a str | { parser ( input ) . map_err ( | e | match e { nom :: Err :: Error ( e2 ) => nom :: Err :: Error ( f ( e2 ) ) , nom :: Err :: Failure ( e2 ) => nom :: Err :: Failure ( f ( e2 ) ) , nom :: Err :: Incomplete ( _ ) => { unreachable ! ( " " ) } } ) } }
Wraps a parser and replaces its error by calling the given 'f' function.
Wraps a parser and replaces its error by calling the given ' f ' function .
parser
Parser
f
ErrorMapper
parser
Parser
f
ErrorMapper