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>
impl<R> Error for ErrorVariant<R>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns 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()
Source§impl<R: Hash> Hash for ErrorVariant<R>
impl<R: Hash> Hash for ErrorVariant<R>
Source§impl<R: PartialEq> PartialEq for ErrorVariant<R>
impl<R: PartialEq> PartialEq for ErrorVariant<R>
impl<R: Eq> Eq for ErrorVariant<R>
impl<R> StructuralPartialEq for ErrorVariant<R>
Auto Trait Implementations§
impl<R> Freeze for ErrorVariant<R>
impl<R> RefUnwindSafe for ErrorVariant<R>where
R: RefUnwindSafe,
impl<R> Send for ErrorVariant<R>where
R: Send,
impl<R> Sync for ErrorVariant<R>where
R: Sync,
impl<R> Unpin for ErrorVariant<R>where
R: Unpin,
impl<R> UnwindSafe for ErrorVariant<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)