Trait nom_supreme::final_parser::ExtractContext [−][src]
pub trait ExtractContext<I, T> {
fn extract_context(self, original_input: I) -> T;
}
Expand description
Trait for recombining error information with the original input.
This trait is used to take the context information attached to nom errors- specifically, the tail of the input indicating the location of the input- and recombine it with the original input to produce an error with something more useful for error reporting.
Typically, it looks like ExtractContext<I, E<T>> for E<I>
. This
indicates that some error type E
, which is generic over the input type,
can be converted into another variant of that error, using T
instead of
I
to hold the result context. Often this context conversion can happen
with RecreateContext
.
Required methods
fn extract_context(self, original_input: I) -> T
fn extract_context(self, original_input: I) -> T
Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information.
For example, for a string, 1 possible context extraction would be the Location (line and column number) in the original input where the error indicated by self occurred.
Implementations on Foreign Types
impl<I, T> ExtractContext<I, VerboseError<T>> for VerboseError<I> where
T: RecreateContext<I>,
I: Clone,
impl<I, T> ExtractContext<I, VerboseError<T>> for VerboseError<I> where
T: RecreateContext<I>,
I: Clone,
impl<T, E1, E2, I> ExtractContext<I, Result<T, E2>> for Result<T, E1> where
E1: ExtractContext<I, E2>,
impl<T, E1, E2, I> ExtractContext<I, Result<T, E2>> for Result<T, E1> where
E1: ExtractContext<I, E2>,
extract_context
can be used directly on Result
values that have an
error with ExtractContext