This commit is contained in:
Folkert 2021-02-09 00:43:35 +01:00
parent 0ad975113c
commit 963e7dee6a
2 changed files with 74 additions and 108 deletions

View file

@ -1243,11 +1243,9 @@ macro_rules! one_of_with_error {
};
}
pub fn specialize<'a, P, T, X, Y>(
map_error: fn(X, Row, Col) -> Y,
parser: P,
) -> impl Parser<'a, T, Y>
pub fn specialize<'a, F, P, T, X, Y>(map_error: F, parser: P) -> impl Parser<'a, T, Y>
where
F: Fn(X, Row, Col) -> Y,
P: Parser<'a, T, X>,
Y: 'a,
{
@ -1257,13 +1255,12 @@ where
}
}
pub fn specialize_ref<'a, P, T, X, Y>(
map_error: fn(&'a X, Row, Col) -> Y,
parser: P,
) -> impl Parser<'a, T, Y>
pub fn specialize_ref<'a, F, P, T, X, Y>(map_error: F, parser: P) -> impl Parser<'a, T, Y>
where
F: Fn(&'a X, Row, Col) -> Y,
P: Parser<'a, T, X>,
Y: 'a,
X: 'a,
{
move |a, s| match parser.parse(a, s) {
Ok(t) => Ok(t),