Remove unnecessary dynamic dispatch.
This commit is contained in:
		
							parent
							
								
									b17429e05c
								
							
						
					
					
						commit
						8ae942a6fc
					
				| @ -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(¶graph_end)), | ||||
|         })); | ||||
|     let ret = { | ||||
|         context_many_till( | ||||
|             ¶graph_context, | ||||
|             &flat_text_element, | ||||
|             &context_paragraph_end, | ||||
|         )(i) | ||||
|     }; | ||||
|     let ret = | ||||
|         { context_many_till(¶graph_context, flat_text_element, context_paragraph_end)(i) }; | ||||
|     ret | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander