Using a mutable reference breaks clone.
This commit is contained in:
		
							parent
							
								
									112aba3137
								
							
						
					
					
						commit
						add717071c
					
				| @ -2,9 +2,8 @@ use nom::branch::alt; | ||||
| use nom::error::VerboseError; | ||||
| use nom::IResult; | ||||
| 
 | ||||
| #[derive(Clone)] | ||||
| pub struct NomContext<'a> { | ||||
|     pub fail_matcher: &'a dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, | ||||
|     pub fail_matcher: &'a mut dyn FnMut(&str) -> 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, | ||||
| @ -12,7 +11,7 @@ pub struct NomContext<'a> { | ||||
| 
 | ||||
| impl<'a> NomContext<'a> { | ||||
|     pub fn new( | ||||
|         fail_matcher: &'a dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, | ||||
|         fail_matcher: &'a mut dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, | ||||
|     ) -> Self { | ||||
|         NomContext { | ||||
|             fail_matcher, | ||||
|  | ||||
| @ -133,7 +133,7 @@ pub fn paragraph_end(input: &str) -> Res<&str, &str> { | ||||
| } | ||||
| 
 | ||||
| pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> { | ||||
|     let initial_context = NomContext::new(¶graph_end); | ||||
|     let initial_context = NomContext::new(&mut paragraph_end); | ||||
|     todo!() | ||||
|     // many1(parser_with_context!(paragraph)(initial_context))(input)
 | ||||
| } | ||||
|  | ||||
| @ -25,5 +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)?; | ||||
|     todo!() | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander