Trait winnow::error::ParseError

source ·
pub trait ParseError<I>: Sized {
    // Required methods
    fn from_error_kind(input: I, kind: ErrorKind) -> Self;
    fn append(self, input: I, kind: ErrorKind) -> Self;

    // Provided methods
    fn assert(input: I, _message: &'static str) -> Self
       where I: Debug { ... }
    fn or(self, other: Self) -> Self { ... }
}
Expand description

The basic Parser trait for errors

It provides methods to create an error from some combinators, and combine existing errors in combinators like alt.

Required Methods§

source

fn from_error_kind(input: I, kind: ErrorKind) -> Self

Creates an error from the input position and an ErrorKind

source

fn append(self, input: I, kind: ErrorKind) -> Self

Like ParseError::from_error_kind but merges it with the existing error.

This is useful when backtracking through a parse tree, accumulating error context on the way.

Provided Methods§

source

fn assert(input: I, _message: &'static str) -> Selfwhere I: Debug,

Process a parser assertion

source

fn or(self, other: Self) -> Self

Combines errors from two different parse branches.

For example, this would be used by alt to report the error from each case.

Implementations on Foreign Types§

source§

impl<I> ParseError<I> for ()

source§

fn from_error_kind(_: I, _: ErrorKind) -> Self

source§

fn append(self, _: I, _: ErrorKind) -> Self

Implementors§

source§

impl<I> ParseError<I> for Error<I>

source§

impl<I> ParseError<I> for VerboseError<I>

source§

impl<I, E: ParseError<I>> ParseError<I> for ErrMode<E>