From 112aba3137c16af641ade742472d926f5b4a3c73 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 14 Oct 2022 20:17:48 -0400 Subject: [PATCH] Adding lifetimes. --- src/parser/nom_context.rs | 10 ++++++---- src/parser/text_element_parser.rs | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/parser/nom_context.rs b/src/parser/nom_context.rs index efa431ee..1dab499d 100644 --- a/src/parser/nom_context.rs +++ b/src/parser/nom_context.rs @@ -3,15 +3,17 @@ use nom::error::VerboseError; use nom::IResult; #[derive(Clone)] -pub struct NomContext { - pub fail_matcher: &dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, +pub struct NomContext<'a> { + pub fail_matcher: &'a 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: &dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>) -> Self { +impl<'a> NomContext<'a> { + pub fn new( + fail_matcher: &'a dyn FnMut(&str) -> IResult<&str, &str, VerboseError<&str>>, + ) -> Self { NomContext { fail_matcher, can_match_bold: true, diff --git a/src/parser/text_element_parser.rs b/src/parser/text_element_parser.rs index 3c64f949..a51e3bc3 100644 --- a/src/parser/text_element_parser.rs +++ b/src/parser/text_element_parser.rs @@ -20,3 +20,10 @@ use nom::error::VerboseError; use nom::multi::many_till; use nom::sequence::tuple; use nom::IResult; + +fn flat_text_element<'s, 'r>( + i: &'s str, + context: &'r mut NomContext, +) -> Res<&'s str, TextElement<'s>> { + todo!() +}