Adding lifetimes.

This commit is contained in:
Tom Alexander 2022-10-14 20:17:48 -04:00
parent 0cd3300444
commit 112aba3137
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 13 additions and 4 deletions

View File

@ -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,

View File

@ -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!()
}