Enum pest::Error [] [src]

pub enum Error<'i, R> {
    ParsingError {
        positives: Vec<R>,
        negatives: Vec<R>,
        pos: Position<'i>,
    },
    CustomErrorPos {
        message: String,
        pos: Position<'i>,
    },
    CustomErrorSpan {
        message: String,
        span: Span<'i>,
    },
}

An enum which defines possible errors.

Variants

Generated parsing error with expected and unexpected Rules and a position

Fields of ParsingError

Positive attempts

Negative attempts

Deepest position of attempts

Custom error with a message and a position

Fields of CustomErrorPos

Short explanation

Error Position for formatting

Custom error with a message and a span defined by a start and end position

Fields of CustomErrorSpan

Short explanation

Error Span for formatting

Methods

impl<'i, R: RuleType> Error<'i, R>
[src]

[src]

Renames all Rules from a ParsingError variant returning a CustomErrorPos. It does nothing when called on CustomErrorPos and CustomErrorSpan variants.

Useful in order to rename verbose rules or have detailed per-Rule formatting.

Examples

Error::ParsingError {
    positives: vec![Rule::open_paren],
    negatives: vec![Rule::closed_paren],
    pos: pos
}.renamed_rules(|rule| {
    match *rule {
        Rule::open_paren => "(".to_owned(),
        Rule::closed_paren => "closed paren".to_owned()
    }
});

Trait Implementations

impl<'i, R: Clone> Clone for Error<'i, R>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<'i, R: Debug> Debug for Error<'i, R>
[src]

[src]

Formats the value using the given formatter.

impl<'i, R: Eq> Eq for Error<'i, R>
[src]

impl<'i, R: Hash> Hash for Error<'i, R>
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl<'i, R: PartialEq> PartialEq for Error<'i, R>
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<'i, R: Debug> Display for Error<'i, R>
[src]

[src]

Formats the value using the given formatter. Read more

impl<'i, R: Debug> Error for Error<'i, R>
[src]

[src]

A short description of the error. Read more

1.0.0
[src]

The lower-level cause of this error, if any. Read more