From 8a6868f29929c4de85628da1f7e1d613562c6765 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 14 Oct 2022 20:52:49 -0400 Subject: [PATCH] Added boxes. --- src/parser/nom_context.rs | 22 +++++++++++----------- src/parser/text.rs | 2 +- src/parser/text_element_parser.rs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index affe0bbd..d62a3c44 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -2,16 +2,16 @@ use nom::branch::alt; use nom::error::VerboseError; use nom::IResult; -pub struct NomContext<'a> { - pub fail_matcher: &'a mut dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, +pub struct NomContext { + pub fail_matcher: Box IResult<&str, &str, VerboseError<&str>>>, /// You can't have nested bolds or links in org-mode pub can_match_bold: bool, pub can_match_link: bool, } -impl<'a> NomContext<'a> { +impl NomContext { pub fn new( - fail_matcher: &'a mut dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, + fail_matcher: Box IResult<&str, &str, VerboseError<&str>>>, ) -> Self { NomContext { fail_matcher, @@ -20,13 +20,13 @@ impl<'a> NomContext<'a> { } } - pub fn with_additional_fail_matcher<'o, 'c: 'a + 'o>(&self, other: &'o mut dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>) -> NomContext<'c> { - let new_matcher = alt((&self.fail_matcher, other)); - NomContext { - fail_matcher: new_matcher, - can_match_bold: self.can_match_bold, - can_match_link: self.can_match_link - } + pub fn with_additional_fail_matcher<>(&self, other: Box IResult<&str, &str, VerboseError<&str>>>) -> NomContext { + // let new_matcher = alt((&self.fail_matcher, other)); + // NomContext { + // fail_matcher: new_matcher, + // can_match_bold: self.can_match_bold, + // can_match_link: self.can_match_link + // } todo!() } } diff --git a/src/parser/text.rs b/src/parser/text.rs index 1826228b..77ec2444 100644 --- a/src/parser/text.rs +++ b/src/parser/text.rs @@ -133,7 +133,7 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> { } pub fn document(input: &str) -> Res<&str, Vec<(Vec, &str)>> { - let initial_context = NomContext::new(&mut paragraph_end); + let initial_context = NomContext::new(Box::new(paragraph_end)); todo!() // many1(parser_with_context!(paragraph)(initial_context))(input) } diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 8dcb96ba..d3681943 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -25,6 +25,6 @@ fn flat_text_element<'s, 'r>( i: &'s str, context: &'r mut NomContext, ) -> Res<&'s str, TextElement<'s>> { - not(&mut context.fail_matcher)(i)?; + // not(&mut context.fail_matcher)(i)?; todo!() }