use std::cell::RefCell; use std::rc::Rc; use nom::branch::alt; use nom::combinator::not; use nom::error::VerboseError; use nom::IResult; use nom::Parser; type Link = Option>>; type Matcher = dyn for<'s> Fn(&'s str) -> IResult<&'s str, &'s str, VerboseError<&'s str>>; struct Node { elem: T, next: Link, } pub struct List { head: Link, } impl List { pub fn new() -> Self { List { head: None } } pub fn push(&mut self, element: T) { let new_node = Box::new(Node { elem: element, next: self.head.take(), }); self.head = Some(new_node); } } struct ContextElement<'r> { fail_matcher: ChainBehavior<'r>, } enum ChainBehavior<'r> { AndParent(Option<&'r Matcher>), IgnoreParent(Option<&'r Matcher>), }