Enum pest::error::ErrorVariant
source · pub enum ErrorVariant<R> {
ParsingError {
positives: Vec<R>,
negatives: Vec<R>,
},
CustomError {
message: String,
},
}
Expand description
Different kinds of parsing errors.
Variants§
ParsingError
Generated parsing error with expected and unexpected Rule
s
CustomError
Custom error with a message
Implementations§
source§impl<R: RuleType> ErrorVariant<R>
impl<R: RuleType> ErrorVariant<R>
sourcepub fn message(&self) -> Cow<'_, str>
pub fn message(&self) -> Cow<'_, str>
Returns the error message for ErrorVariant
If ErrorVariant
is CustomError
, it returns a
Cow::Borrowed
reference to message
. If ErrorVariant
is ParsingError
, a
Cow::Owned
containing “expected ErrorVariant::ParsingError::positives ErrorVariant::ParsingError::negatives” is returned.
Examples
let variant = ErrorVariant::<()>::CustomError {
message: String::from("unexpected error")
};
println!("{}", variant.message());
Trait Implementations§
source§impl<R: Clone> Clone for ErrorVariant<R>
impl<R: Clone> Clone for ErrorVariant<R>
source§fn clone(&self) -> ErrorVariant<R>
fn clone(&self) -> ErrorVariant<R>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<R: Debug> Debug for ErrorVariant<R>
impl<R: Debug> Debug for ErrorVariant<R>
source§impl<R: RuleType> Display for ErrorVariant<R>
impl<R: RuleType> Display for ErrorVariant<R>
source§impl<R> Error for ErrorVariant<R>where
Self: Debug + Display,
impl<R> Error for ErrorVariant<R>where
Self: Debug + Display,
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()