pub struct ContextError<C = StrContext> { /* private fields */ }
Expand description
Accumulate context while backtracking errors
See the [tutorial][crate::_tutorial::chapter_7#error-adaptation-and-rendering] for an example of how to adapt this to an application error with custom rendering.
Implementations§
Source§impl<C> ContextError<C>
impl<C> ContextError<C>
Sourcepub fn extend<I: IntoIterator<Item = C>>(&mut self, context: I)
pub fn extend<I: IntoIterator<Item = C>>(&mut self, context: I)
Add more context
Sourcepub fn context(&self) -> impl Iterator<Item = &C>
Available on crate feature alloc
only.
pub fn context(&self) -> impl Iterator<Item = &C>
alloc
only.Access context from Parser::context
Trait Implementations§
Source§impl<C, I: Stream> AddContext<I, C> for ContextError<C>
impl<C, I: Stream> AddContext<I, C> for ContextError<C>
Source§fn add_context(
self,
_input: &I,
_token_start: &<I as Stream>::Checkpoint,
context: C,
) -> Self
fn add_context( self, _input: &I, _token_start: &<I as Stream>::Checkpoint, context: C, ) -> Self
Append to an existing error custom data Read more
Source§impl<C: Clone> Clone for ContextError<C>
impl<C: Clone> Clone for ContextError<C>
Source§impl<C: Debug> Debug for ContextError<C>
impl<C: Debug> Debug for ContextError<C>
Source§impl<C> Default for ContextError<C>
impl<C> Default for ContextError<C>
Source§impl Display for ContextError<StrContext>
impl Display for ContextError<StrContext>
Source§impl<C> ErrorConvert<ContextError<C>> for ContextError<C>
impl<C> ErrorConvert<ContextError<C>> for ContextError<C>
Source§fn convert(self) -> ContextError<C>
fn convert(self) -> ContextError<C>
Transform to another error type
Source§impl<C, I, E: Error + Send + Sync + 'static> FromExternalError<I, E> for ContextError<C>
Available on crate feature std
only.
impl<C, I, E: Error + Send + Sync + 'static> FromExternalError<I, E> for ContextError<C>
Available on crate feature
std
only.Source§fn from_external_error(_input: &I, e: E) -> Self
fn from_external_error(_input: &I, e: E) -> Self
Like
ParserError::from_input
but also include an external error.Source§impl<I: Stream, C> ParserError<I> for ContextError<C>
impl<I: Stream, C> ParserError<I> for ContextError<C>
Source§type Inner = ContextError<C>
type Inner = ContextError<C>
Generally,
Self
Read moreSource§fn from_input(_input: &I) -> Self
fn from_input(_input: &I) -> Self
Creates an error from the input position
Source§fn into_inner(self) -> Result<Self::Inner, Self>
fn into_inner(self) -> Result<Self::Inner, Self>
Unwrap the mode, returning the underlying error, if present
Source§fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
fn assert(input: &I, _message: &'static str) -> Selfwhere
I: Debug,
Process a parser assertion
Source§fn incomplete(input: &I, _needed: Needed) -> Self
fn incomplete(input: &I, _needed: Needed) -> Self
There was not enough data to determine the appropriate action Read more
Source§fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
fn append(self, _input: &I, _token_start: &<I as Stream>::Checkpoint) -> Self
Like
ParserError::from_input
but merges it with the existing error. Read moreSource§fn is_backtrack(&self) -> bool
fn is_backtrack(&self) -> bool
Is backtracking and trying new parse branches allowed?
Source§impl<C: PartialEq> PartialEq for ContextError<C>
impl<C: PartialEq> PartialEq for ContextError<C>
Auto Trait Implementations§
impl<C> Freeze for ContextError<C>
impl<C = StrContext> !RefUnwindSafe for ContextError<C>
impl<C> Send for ContextError<C>where
C: Send,
impl<C> Sync for ContextError<C>where
C: Sync,
impl<C> Unpin for ContextError<C>where
C: Unpin,
impl<C = StrContext> !UnwindSafe for ContextError<C>
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,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes