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

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

extract_context can be used directly on Result values that have an error with ExtractContext

Implementors