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
ParsingError
Generated parsing error with expected and unexpected Rule
s and a position
Fields of ParsingError
positives: Vec<R> | Positive attempts |
negatives: Vec<R> | Negative attempts |
pos: Position<'i> | Deepest position of attempts |
CustomErrorPos
Custom error with a message and a position
Fields of CustomErrorPos
message: String | Short explanation |
pos: Position<'i> | Error |
CustomErrorSpan
Custom error with a message and a span defined by a start and end position
Fields of CustomErrorSpan
message: String | Short explanation |
span: Span<'i> | Error |
Methods
impl<'i, R: RuleType> Error<'i, R>
[src]
fn renamed_rules<F>(self, f: F) -> Error<'i, R> where
F: FnMut(&R) -> String,
[src]
F: FnMut(&R) -> String,
Renames all Rule
s 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]
fn clone(&self) -> Error<'i, R>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'i, R: Debug> Debug for Error<'i, R>
[src]
impl<'i, R: Eq> Eq for Error<'i, R>
[src]
impl<'i, R: Hash> Hash for Error<'i, R>
[src]
fn hash<__HR: Hasher>(&self, __arg_0: &mut __HR)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'i, R: PartialEq> PartialEq for Error<'i, R>
[src]
fn eq(&self, __arg_0: &Error<'i, R>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Error<'i, R>) -> bool
[src]
This method tests for !=
.
impl<'i, R: Debug> Display for Error<'i, R>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more