Enum ErrorVariant

enum ErrorVariant<R>

Different kinds of parsing errors.

Variants

ParsingError { positives: alloc::vec::Vec<R>, negatives: alloc::vec::Vec<R> }

Generated parsing error with expected and unexpected Rules

CustomError { message: alloc::string::String }

Custom error with a message

Implementations

impl<R: RuleType> ErrorVariant<R>

fn message(self: &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

# use pest::error::ErrorVariant;
let variant = ErrorVariant::<()>::CustomError {
    message: String::from("unexpected error")
};

println!("{}", variant.message());

impl<R> Error for ErrorVariant<R>

impl<R> Freeze for ErrorVariant<R>

impl<R> RefUnwindSafe for ErrorVariant<R>

impl<R> Send for ErrorVariant<R>

impl<R> StructuralPartialEq for ErrorVariant<R>

impl<R> Sync for ErrorVariant<R>

impl<R> Unpin for ErrorVariant<R>

impl<R> UnsafeUnpin for ErrorVariant<R>

impl<R> UnwindSafe for ErrorVariant<R>

impl<R: $crate::clone::Clone> Clone for ErrorVariant<R>

fn clone(self: &Self) -> ErrorVariant<R>

impl<R: $crate::cmp::Eq> Eq for ErrorVariant<R>

impl<R: $crate::cmp::PartialEq> PartialEq for ErrorVariant<R>

fn eq(self: &Self, other: &ErrorVariant<R>) -> bool

impl<R: $crate::fmt::Debug> Debug for ErrorVariant<R>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<R: $crate::hash::Hash> Hash for ErrorVariant<R>

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl<R: RuleType> Display for ErrorVariant<R>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T> Any for ErrorVariant<R>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for ErrorVariant<R>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for ErrorVariant<R>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for ErrorVariant<R>

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for ErrorVariant<R>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for ErrorVariant<R>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for ErrorVariant<R>

fn to_string(self: &Self) -> String

impl<T, U> Into for ErrorVariant<R>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for ErrorVariant<R>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for ErrorVariant<R>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>