pub struct Errors<T, R, P> {
    pub position: P,
    pub errors: Vec<Error<T, R>>,
}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§
Source§impl<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>)
 
pub fn add_error(&mut self, error: Error<T, R>)
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>
 
pub fn merge(self, other: Errors<T, R, P>) -> Errors<T, R, P>
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§
Source§impl<T, R, P> Error for Errors<T, R, P>
 
impl<T, R, P> Error for Errors<T, R, P>
Source§fn description(&self) -> &str
 
fn description(&self) -> &str
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
 
fn source(&self) -> Option<&(dyn Error + 'static)>
Source§impl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Item, Range, Position>
 
impl<Item, Range, Position> ParseError<Item, Range, Position> for Errors<Item, Range, Position>
type StreamError = Error<Item, Range>
Source§fn from_error(position: Position, err: Self::StreamError) -> Self
 
fn from_error(position: Position, err: Self::StreamError) -> Self
ParseError from a single Self::StreamErrorfn position(&self) -> Position
Source§fn set_position(&mut self, position: Position)
 
fn set_position(&mut self, position: Position)
ParseErrorSource§fn merge(self, other: Self) -> Self
 
fn merge(self, other: Self) -> Self
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.Source§fn add(&mut self, err: Self::StreamError)
 
fn add(&mut self, err: Self::StreamError)
Source§fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F)
 
fn set_expected<F>(self_: &mut Tracked<Self>, info: Self::StreamError, f: F)
info as the only Expected error of selfSource§fn clear_expected(&mut self)
 
fn clear_expected(&mut self)
selffn is_unexpected_end_of_input(&self) -> bool
Source§fn into_other<T>(self) -> Twhere
    T: ParseError<Item, Range, Position>,
 
fn into_other<T>(self) -> Twhere
    T: ParseError<Item, Range, Position>,
self into another ParseError