From c1778a4f12040d5fd7d8e4c24e9b8aa80f6b8be3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 26 Nov 2022 19:46:59 -0500 Subject: [PATCH] Switching to generics. --- src/parser/text_element_parser.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index a57832d0..37902321 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -32,21 +32,23 @@ use nom::multi::many1; use nom::multi::many_till; use nom::sequence::tuple; use nom::IResult; +use nom::InputLength; +use nom::Parser; use tracing::instrument; use tracing::trace; -fn context_many_till< - 'r, - M: for<'s> FnMut(&'s str) -> IResult<&'s str, TextElement<'s>, VerboseError<&'s str>>, - T: for<'s> FnMut(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>, ->( +fn context_many_till<'r, I, O, E, F, M, T>( context: &'r OrgModeContextNode<'r>, mut many_matcher: M, mut till_matcher: T, -) -> impl for<'s> FnMut( - &'s str, -) -> IResult<&'s str, (Vec>, &'s str), VerboseError<&'s str>> { - |i| { +) -> impl FnMut(I) -> IResult, F), E> +where + I: Clone + InputLength, + M: Parser, + T: Parser, + E: ParseError, +{ + move |mut i: I| { // todo todo!() } @@ -68,7 +70,7 @@ pub fn paragraph<'s, 'r>( let paragraph_context = context.with_additional_fail_matcher(¶graph_end); let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context); let ret = context_many_till(¶graph_context, text_element_parser, paragraph_end)(i); - // let ret = many_till(text_element_parser, paragraph_end)(i); + let ret = many_till(text_element_parser, paragraph_end)(i); ret }