use nom::branch::alt; use nom::error::VerboseError; use nom::IResult; use std::cell::RefCell; use std::rc::Rc; pub struct NomContext { pub fail_matcher: Box IResult>, /// You can't have nested bolds in org-mode pub can_match_bold: bool, pub can_match_link: bool, } impl NomContext { pub fn new(fail_matcher: Box IResult>) -> Self { NomContext { fail_matcher: fail_matcher, can_match_bold: true, can_match_link: true, } } // pub fn with_no_bold(&self) -> NomContext { // NomContext { // fail_matcher: self.fail_matcher.clone(), // can_match_bold: false, // can_match_link: self.can_match_link, // } // } // pub fn with_additional_fail_matcher(&self, additional_matcher: G) -> NomContext // where // G: for<'a> FnMut(I) -> IResult, // { // let new_fail_matcher = alt((self.fail_matcher, additional_matcher)); // NomContext { // fail_matcher: Rc::new(RefCell::new(new_fail_matcher)), // can_match_bold: self.can_match_bold, // can_match_link: self.can_match_link, // } // } }