pub enum RichReason<'a, T> {
ExpectedFound {
expected: Vec<RichPattern<'a, T>>,
found: Option<MaybeRef<'a, T>>,
},
Custom(String),
}Expand description
The reason for a Rich error.
Variants§
ExpectedFound
An unexpected input was found
Fields
§
expected: Vec<RichPattern<'a, T>>The tokens expected
Custom(String)
An error with a custom message
Implementations§
Source§impl<'a, T> RichReason<'a, T>
impl<'a, T> RichReason<'a, T>
Sourcepub fn found(&self) -> Option<&T>
pub fn found(&self) -> Option<&T>
Return the token that was found by this error reason. None implies that the end of input was expected.
Sourcepub fn into_owned<'b>(self) -> RichReason<'b, T>where
T: Clone,
pub fn into_owned<'b>(self) -> RichReason<'b, T>where
T: Clone,
Convert this reason into an owned version of itself by cloning any borrowed internal tokens, if necessary.
Sourcepub fn map_token<U, F: FnMut(T) -> U>(self, f: F) -> RichReason<'a, U>where
T: Clone,
pub fn map_token<U, F: FnMut(T) -> U>(self, f: F) -> RichReason<'a, U>where
T: Clone,
Transform this RichReason’s tokens using the given function.
This is useful when you wish to combine errors from multiple compilation passes (lexing and parsing, say) where
the token type for each pass is different (char vs MyToken, say).
Trait Implementations§
Source§impl<'a, T: Clone> Clone for RichReason<'a, T>
impl<'a, T: Clone> Clone for RichReason<'a, T>
Source§fn clone(&self) -> RichReason<'a, T>
fn clone(&self) -> RichReason<'a, T>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T: Debug> Debug for RichReason<'a, T>
impl<'a, T: Debug> Debug for RichReason<'a, T>
Source§impl<'de, 'a, T> Deserialize<'de> for RichReason<'a, T>where
T: Deserialize<'de>,
impl<'de, 'a, T> Deserialize<'de> for RichReason<'a, T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Display for RichReason<'_, T>where
T: Display,
impl<T> Display for RichReason<'_, T>where
T: Display,
Source§impl<'a, T: Hash> Hash for RichReason<'a, T>
impl<'a, T: Hash> Hash for RichReason<'a, T>
Source§impl<'a, T: Ord> Ord for RichReason<'a, T>
impl<'a, T: Ord> Ord for RichReason<'a, T>
Source§impl<'a, T: PartialEq> PartialEq for RichReason<'a, T>
impl<'a, T: PartialEq> PartialEq for RichReason<'a, T>
Source§impl<'a, T: PartialOrd> PartialOrd for RichReason<'a, T>
impl<'a, T: PartialOrd> PartialOrd for RichReason<'a, T>
Source§impl<'a, T> Serialize for RichReason<'a, T>where
T: Serialize,
impl<'a, T> Serialize for RichReason<'a, T>where
T: Serialize,
impl<'a, T: Eq> Eq for RichReason<'a, T>
impl<'a, T> StructuralPartialEq for RichReason<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for RichReason<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for RichReason<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for RichReason<'a, T>
impl<'a, T> Sync for RichReason<'a, T>where
T: Sync,
impl<'a, T> Unpin for RichReason<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for RichReason<'a, T>where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<'p, T> Seq<'p, T> for T
impl<'p, T> Seq<'p, T> for T
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> S::Spanned
fn with_span(self, span: S) -> S::Spanned
Invokes
WrappingSpan::make_wrapped to wrap an AST node in a span.