Working now that we use clone and manually instantiate it.

This commit is contained in:
Tom Alexander
2022-07-17 18:06:14 -04:00
parent 3519c76c61
commit 8321c071e4
2 changed files with 21 additions and 18 deletions

View File

@@ -26,7 +26,8 @@ pub fn flat_text_element<'a, F>(
context: &mut NomContext<F>,
) -> Res<&'a str, TextElement<'a>>
where
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>,
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>
+ std::clone::Clone,
{
not(&mut context.fail_matcher)(i)?;
if context.can_match_bold {
@@ -59,7 +60,11 @@ where
F: Clone,
{
not(&mut context.fail_matcher)(i)?;
let new_context = context.without_bold();
let mut old_fail_matcher_clone = context.fail_matcher.clone();
let mut new_context =
NomContext::new(move |i| alt((recognize(bold_end), &mut old_fail_matcher_clone))(i));
new_context.can_match_bold = context.can_match_bold;
new_context.can_match_link = context.can_match_link;
let text_element_parser = parser_with_context!(flat_text_element)(new_context);
map(
recognize(tuple((