Struct pest_consume::Error [−][src]
pub struct Error<R> { pub variant: ErrorVariant<R>, pub location: InputLocation, pub line_col: LineColLocation, // some fields omitted }
Expand description
Parse-related error type.
Fields
variant: ErrorVariant<R>
Variant of the error
location: InputLocation
Location within the input string
line_col: LineColLocation
Line/column within the input string
Implementations
Creates Error
from ErrorVariant
and Position
.
Examples
let error = Error::new_from_pos( ErrorVariant::ParsingError { positives: vec![Rule::open_paren], negatives: vec![Rule::closed_paren] }, pos ); println!("{}", error);
Creates Error
from ErrorVariant
and Span
.
Examples
let error = Error::new_from_span( ErrorVariant::ParsingError { positives: vec![Rule::open_paren], negatives: vec![Rule::closed_paren] }, span ); println!("{}", error);
Returns Error
variant with path
which is shown when formatted with Display
.
Examples
Error::new_from_pos( ErrorVariant::ParsingError { positives: vec![Rule::open_paren], negatives: vec![Rule::closed_paren] }, pos ).with_path("file.rs");
Renames all Rule
s if this is a ParsingError
. It does nothing when called on a
CustomError
.
Useful in order to rename verbose rules or have detailed per-Rule
formatting.
Examples
Error::new_from_pos( ErrorVariant::ParsingError { positives: vec![Rule::open_paren], negatives: vec![Rule::closed_paren] }, pos ).renamed_rules(|rule| { match *rule { Rule::open_paren => "(".to_owned(), Rule::closed_paren => "closed paren".to_owned() } });
Trait Implementations
Auto Trait Implementations
impl<R> RefUnwindSafe for Error<R> where
R: RefUnwindSafe,
impl<R> UnwindSafe for Error<R> where
R: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more