Mutable push.
This commit is contained in:
		
							parent
							
								
									1487f7d96b
								
							
						
					
					
						commit
						f2ddf6451c
					
				| @ -7,41 +7,38 @@ use nom::error::VerboseError; | ||||
| use nom::IResult; | ||||
| use nom::Parser; | ||||
| 
 | ||||
| // type ContextReference<'r, T> = Option<ContextLayer<'r, T>>;
 | ||||
| // type MatcherRef = dyn for<'s> FnMut(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>;
 | ||||
| type Link<T> = Option<Box<Node<T>>>; | ||||
| type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>; | ||||
| 
 | ||||
| // pub struct ContextLayer<'r, T> {
 | ||||
| //     data: T,
 | ||||
| //     parent: ContextReference<'r, T>,
 | ||||
| // }
 | ||||
| struct Node<T> { | ||||
|     elem: T, | ||||
|     next: Link<T>, | ||||
| } | ||||
| 
 | ||||
| // pub struct TestContext<'r, T> {
 | ||||
| //     head: ContextReference<'r, T>,
 | ||||
| // }
 | ||||
| pub struct List<T> { | ||||
|     head: Link<T>, | ||||
| } | ||||
| 
 | ||||
| // pub struct ContextData<'r> {
 | ||||
| //     fail_matcher: ChainBehavior<'r>,
 | ||||
| // }
 | ||||
| impl<T> List<T> { | ||||
|     pub fn new() -> Self { | ||||
|         List { head: None } | ||||
|     } | ||||
| 
 | ||||
| // impl<'r> TestContext<'r, ContextData<'r>> {
 | ||||
| //     pub fn new() -> Self {
 | ||||
| //         TestContext { head: None }
 | ||||
| //     }
 | ||||
|     pub fn push(&mut self, element: T) { | ||||
|         let new_node = Box::new(Node { | ||||
|             elem: element, | ||||
|             next: self.head.take(), | ||||
|         }); | ||||
| 
 | ||||
| //     pub fn with_additional_fail_matcher<'subr>(
 | ||||
| //         &self,
 | ||||
| //         additional_fail_matcher: &'subr MatcherRef,
 | ||||
| //     ) -> TestContext<'subr, ContextData<'subr>> {
 | ||||
| //         // TestContext {
 | ||||
| //         //     head: Some(
 | ||||
|         self.head = Some(new_node); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| //         //     )
 | ||||
| //         // }
 | ||||
| //         todo!()
 | ||||
| //     }
 | ||||
| // }
 | ||||
| struct ContextElement<'r> { | ||||
|     fail_matcher: ChainBehavior<'r>, | ||||
| } | ||||
| 
 | ||||
| // enum ChainBehavior<'r> {
 | ||||
| //     AndParent(Option<&'r MatcherRef>),
 | ||||
| //     IgnoreParent(Option<&'r MatcherRef>),
 | ||||
| // }
 | ||||
| enum ChainBehavior<'r> { | ||||
|     AndParent(Option<&'r Matcher>), | ||||
|     IgnoreParent(Option<&'r Matcher>), | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander