Remove unnecessary dynamic dispatch.

This commit is contained in:
Tom Alexander 2022-12-03 23:13:21 -05:00
parent b17429e05c
commit 8ae942a6fc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 11 additions and 11 deletions

View File

@ -41,14 +41,16 @@ use tracing::trace;
type UnboundMatcher<'r, I, O, E> = dyn Fn(Context<'r>, I) -> IResult<I, O, E>;
fn context_many_till<'r, I, O, E, F>(
fn context_many_till<'r, I, O, E, F, M, T>(
context: Context<'r>,
mut many_matcher: &UnboundMatcher<'r, I, O, E>,
mut till_matcher: &UnboundMatcher<'r, I, F, E>,
mut many_matcher: M,
mut till_matcher: T,
) -> impl FnMut(I) -> IResult<I, (Vec<O>, F), E>
where
I: Clone + InputLength,
E: ParseError<I>,
M: Fn(Context<'r>, I) -> IResult<I, O, E>,
T: Fn(Context<'r>, I) -> IResult<I, F, E>,
{
move |mut i: I| {
let mut ret = Vec::new();
@ -89,7 +91,10 @@ pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> {
ret
}
pub fn context_paragraph_end<'s, 'r>(context: Context<'r>, input: &str) -> Res<&str, &str> {
pub fn context_paragraph_end<'s, 'r>(
context: Context<'r>,
input: &'s str,
) -> Res<&'s str, &'s str> {
paragraph_end(input)
}
@ -103,13 +108,8 @@ pub fn paragraph<'s, 'r>(
context.with_additional_node(ContextElement::FailMatcherNode(FailMatcherNode {
fail_matcher: ChainBehavior::AndParent(Some(&paragraph_end)),
}));
let ret = {
context_many_till(
&paragraph_context,
&flat_text_element,
&context_paragraph_end,
)(i)
};
let ret =
{ context_many_till(&paragraph_context, flat_text_element, context_paragraph_end)(i) };
ret
}