Expand description
Struct which hold information about an error that occurred at a specific position.
Can hold multiple instances of Error if more that one error occurred in the same position.
Fields
position: PThe position where the error occurred
errors: Vec<Error<T, R>>A vector containing specific information on what errors occurred at position. Usually
a fully formed message contains one Unexpected error and one or more Expected errors.
Message and Other may also appear (combine never generates these errors on its own)
and may warrant custom handling.
Implementations
sourceimpl<T, R, P> Errors<T, R, P>
impl<T, R, P> Errors<T, R, P>
sourcepub fn new(position: P, error: Error<T, R>) -> Errors<T, R, P>
pub fn new(position: P, error: Error<T, R>) -> Errors<T, R, P>
Constructs a new ParseError which occurred at position.
sourcepub fn empty(position: P) -> Errors<T, R, P>
pub fn empty(position: P) -> Errors<T, R, P>
Constructs an error with no other information than the position it occurred at.
sourcepub fn from_errors(position: P, errors: Vec<Error<T, R>>) -> Errors<T, R, P>
pub fn from_errors(position: P, errors: Vec<Error<T, R>>) -> Errors<T, R, P>
Constructs a ParseError with multiple causes.
sourcepub fn end_of_input(position: P) -> Errors<T, R, P>
pub fn end_of_input(position: P) -> Errors<T, R, P>
Constructs an end of input error. Should be returned by parsers which encounter end of input unexpectedly.
sourcepub fn add_error(&mut self, error: Error<T, R>) where
T: PartialEq,
R: PartialEq,
pub fn add_error(&mut self, error: Error<T, R>) where
T: PartialEq,
R: PartialEq,
Adds an error if error does not exist in this ParseError already (as determined byte
PartialEq).
sourcepub fn set_expected(&mut self, info: Info<T, R>)
pub fn set_expected(&mut self, info: Info<T, R>)
Removes all Expected errors in self and adds info instead.
sourcepub fn merge(self, other: Errors<T, R, P>) -> Errors<T, R, P> where
P: Ord,
T: PartialEq,
R: PartialEq,
pub fn merge(self, other: Errors<T, R, P>) -> Errors<T, R, P> where
P: Ord,
T: PartialEq,
R: PartialEq,
Merges two ParseErrors. If they exist at the same position the errors of other are
added to self (using add_error to skip duplicates). If they are not at the same
position the error furthest ahead are returned, ignoring the other ParseError.
sourcepub fn map_position<F, Q>(self, f: F) -> Errors<T, R, Q> where
F: FnOnce(P) -> Q,
pub fn map_position<F, Q>(self, f: F) -> Errors<T, R, Q> where
F: FnOnce(P) -> Q,
Maps the position to a new value
Trait Implementations
sourceimpl<T, R, P> Error for Errors<T, R, P> where
P: Display + Debug,
T: Display + Debug,
R: Display + Debug,
impl<T, R, P> Error for Errors<T, R, P> where
P: Display + Debug,
T: Display + Debug,
R: Display + Debug,
sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
1.30.0 · sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourceimpl<'a, P> From<Error<Errors<u8, &'a [u8], P>, P>> for Errors<u8, &'a [u8], P> where
P: Ord + Clone,
impl<'a, P> From<Error<Errors<u8, &'a [u8], P>, P>> for Errors<u8, &'a [u8], P> where
P: Ord + Clone,
sourceimpl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Item, Range, Position> where
Item: PartialEq,
Range: PartialEq,
Position: Ord + Clone,
impl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Item, Range, Position> where
Item: PartialEq,
Range: PartialEq,
Position: Ord + Clone,
type StreamError = Error<Item, Range>
sourcefn from_error(position: Position, err: Self::StreamError) -> Self
fn from_error(position: Position, err: Self::StreamError) -> Self
Creates a ParseError from a single Self::StreamError
fn position(&self) -> Position
sourcefn set_position(&mut self, position: Position)
fn set_position(&mut self, position: Position)
Sets the position of this ParseError
sourcefn merge(self, other: Self) -> Self
fn merge(self, other: Self) -> Self
Merges two errors. If they exist at the same position the errors of other are
added to self (using the semantics of add). If they are not at the same
position the error furthest ahead are returned, ignoring the other ParseError. Read more
sourcefn add(&mut self, err: Self::StreamError)
fn add(&mut self, err: Self::StreamError)
Adds a StreamError to self. Read more
sourcefn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F) where
F: FnOnce(&mut Tracked<Self>),
fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F) where
F: FnOnce(&mut Tracked<Self>),
Sets info as the only Expected error of self
sourcefn clear_expected(&mut self)
fn clear_expected(&mut self)
Removes any expected errors currently in self
fn is_unexpected_end_of_input(&self) -> bool
sourcefn into_other<T>(self) -> T where
T: ParseError<Item, Range, Position>,
fn into_other<T>(self) -> T where
T: ParseError<Item, Range, Position>,
Does a best-effort conversion of self into another ParseError
fn add_expected<E>(&mut self, info: E) where
E: for<'s> ErrorInfo<'s, Item, Range>,
fn add_unexpected<E>(&mut self, info: E) where
E: for<'s> ErrorInfo<'s, Item, Range>,
fn add_message<E>(&mut self, info: E) where
E: for<'s> ErrorInfo<'s, Item, Range>,
sourceimpl<Item, Range, Position> ParseErrorInto<Item, Range, Position> for Errors<Item, Range, Position>
impl<Item, Range, Position> ParseErrorInto<Item, Range, Position> for Errors<Item, Range, Position>
fn into_other_error<T, Item2, Range2, Position2>(self) -> T where
T: ParseError<Item2, Range2, Position2>,
Item2: From<Item>,
Range2: From<Range>,
Position2: From<Position>,
impl<T, R, P> StructuralPartialEq for Errors<T, R, P>
Auto Trait Implementations
impl<T, R, P> !RefUnwindSafe for Errors<T, R, P>
impl<T, R, P> Send for Errors<T, R, P> where
P: Send,
R: Send,
T: Send,
impl<T, R, P> Sync for Errors<T, R, P> where
P: Sync,
R: Sync,
T: Sync,
impl<T, R, P> Unpin for Errors<T, R, P> where
P: Unpin,
R: Unpin,
T: Unpin,
impl<T, R, P> !UnwindSafe for Errors<T, R, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more