Going to go back to fn objects in the hope that I don't have to specify lifetimes.
This commit is contained in:
@@ -37,38 +37,13 @@ use nom::IResult;
|
||||
// ))(i)
|
||||
// });
|
||||
|
||||
pub trait ParserWithContext {
|
||||
fn bind_context<'a, 'c>(
|
||||
&mut self,
|
||||
context: &mut NomContext<'c, &'a str, &'a str, VerboseError<&'a str>>,
|
||||
) -> Box<dyn FnMut(&'a str) -> IResult<&'a str, TextElement<'a>, VerboseError<&'a str>>>;
|
||||
}
|
||||
|
||||
impl<F> ParserWithContext for F
|
||||
where
|
||||
F: for<'a, 'c> FnMut(
|
||||
&'a str,
|
||||
&mut NomContext<'c, &'a str, &'a str, VerboseError<&'a str>>,
|
||||
) -> Res<&'a str, TextElement<'a>>,
|
||||
{
|
||||
fn bind_context<'c>(
|
||||
&mut self,
|
||||
context: &mut NomContext<'c, &str, &str, VerboseError<&str>>,
|
||||
) -> Box<
|
||||
(dyn for<'a> FnMut(
|
||||
&'a str,
|
||||
)
|
||||
-> Result<(&'a str, TextElement<'a>), nom::Err<VerboseError<&'a str>>>
|
||||
+ 'static),
|
||||
> {
|
||||
Box::new(|i| self(i, context))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn flat_text_element<'a, 'c>(
|
||||
pub fn flat_text_element<'a, F>(
|
||||
i: &'a str,
|
||||
context: &mut NomContext<'c, &'a str, &'a str, VerboseError<&'a str>>,
|
||||
) -> Res<&'a str, TextElement<'a>> {
|
||||
context: &mut NomContext<F>,
|
||||
) -> Res<&'a str, TextElement<'a>>
|
||||
where
|
||||
F: for<'b> FnMut(&'b str) -> IResult<&'b str, &'b str, VerboseError<&'b str>>,
|
||||
{
|
||||
// not(context.fail_matcher)(i)?;
|
||||
// todo
|
||||
todo!()
|
||||
|
||||
Reference in New Issue
Block a user