From 0cd33004446e56bf18633d71a09301ff80febcdd Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 14 Oct 2022 20:09:09 -0400 Subject: [PATCH] Using trait objects seems good so far. --- src/parser/nom_context.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index 8c77299..efa431e 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -3,21 +3,17 @@ use nom::error::VerboseError; use nom::IResult; #[derive(Clone)] -pub struct NomContext -// where -// F: for<'a> FnMut(&'a str) -> IResult<&'a str, &'a str, VerboseError<&'a str>>, -// F: Clone, -{ - // pub fail_matcher: F, - /// You can't have nested bolds in org-mode +pub struct NomContext { + pub fail_matcher: &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, } impl NomContext { - pub fn new(fail_matcher: F) -> Self { + pub fn new(fail_matcher: &dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>) -> Self { NomContext { - // fail_matcher, + fail_matcher, can_match_bold: true, can_match_link: true, }