Struct Error
struct Error<R> { ... }
Parse-related error type.
Fields
variant: ErrorVariant<R>Variant of the error
location: InputLocationLocation within the input string
line_col: LineColLocationLine/column within the input string
Implementations
impl<R: RuleType> Error<R>
fn new_from_pos(variant: ErrorVariant<R>, pos: Position<'_>) -> Error<R>Creates
ErrorfromErrorVariantandPosition.Examples
# use ; # use Position; # # # # # let input = ""; # let pos = from_start; let error = new_from_pos; println!;fn new_from_span(variant: ErrorVariant<R>, span: Span<'_>) -> Error<R>Creates
ErrorfromErrorVariantandSpan.Examples
# use ; # use ; # # # # # let input = ""; # let start = from_start; # let end = start.clone; # let span = start.span; let error = new_from_span; println!;fn with_path(self: Self, path: &str) -> Error<R>Returns
Errorvariant withpathwhich is shown when formatted withDisplay.Examples
# use ; # use Position; # # # # # let input = ""; # let pos = from_start; new_from_pos.with_path;fn path(self: &Self) -> Option<&str>Returns the path set using [
Error::with_path()].Examples
# use ; # use Position; # # # # # let input = ""; # let pos = from_start; # let error = new_from_pos; let error = error.with_path; assert_eq!;fn line(self: &Self) -> &strReturns the line that the error is on.
fn renamed_rules<F>(self: Self, f: F) -> Error<R> where F: FnMut(&R) -> StringRenames all
Rules if this is aParsingError. It does nothing when called on aCustomError.Useful in order to rename verbose rules or have detailed per-
Ruleformatting.Examples
# use ; # use Position; # # # # # let input = ""; # let pos = from_start; new_from_pos.renamed_rules;fn parse_attempts(self: &Self) -> Option<ParseAttempts<R>>Get detailed information about errored rules sequence. Returns
Some(results)only forParsingError.fn parse_attempts_error(self: &Self, input: &str, rule_to_message: &RuleToMessageFn<R>, is_whitespace: &IsWhitespaceFn) -> Option<Error<R>>Get error message based on parsing attempts. Returns
Nonein case selfparse_attemptsisNone.
impl<R> Error for Error<R>
impl<R> Freeze for Error<R>
impl<R> RefUnwindSafe for Error<R>
impl<R> Send for Error<R>
impl<R> StructuralPartialEq for Error<R>
impl<R> Sync for Error<R>
impl<R> Unpin for Error<R>
impl<R> UnsafeUnpin for Error<R>
impl<R> UnwindSafe for Error<R>
impl<R: $crate::clone::Clone> Clone for Error<R>
fn clone(self: &Self) -> Error<R>
impl<R: $crate::cmp::Eq> Eq for Error<R>
impl<R: $crate::cmp::PartialEq> PartialEq for Error<R>
fn eq(self: &Self, other: &Error<R>) -> bool
impl<R: $crate::fmt::Debug> Debug for Error<R>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<R: $crate::hash::Hash> Hash for Error<R>
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl<R: RuleType> Display for Error<R>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T> Any for Error<R>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Error<R>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Error<R>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Error<R>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Error<R>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Error<R>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for Error<R>
fn to_string(self: &Self) -> String
impl<T, U> Into for Error<R>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Error<R>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Error<R>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>