pub struct ParseError {
pub(crate) span: Option<Range<usize>>,
pub(crate) kind: ParseErrorKind,
}
Expand description
Errors during parsing.
This type should be seen primarily for error reporting and not for catching specific cases. The span and error kind are not guaranteed to be stable over different versions of this library, meaning that a returned error can change from one version to the next. There are simply too many fringe cases that are not easy to classify as a specific error kind. It depends entirely on the specific parser code how an invalid input is categorized.
Consider these examples:
'\
can be seen as- invalid escape in character literal, or
- unterminated character literal.
'''
can be seen as- empty character literal, or
- unescaped quote character in character literal.
0b64
can be seen as- binary integer literal with invalid digit 6, or
- binary integer literal with invalid digit 4, or
- decimal integer literal with invalid digit b, or
- decimal integer literal 0 with unknown type suffix
b64
.
If you want to see more if these examples, feel free to check out the unit tests of this library.
While this library does its best to emit sensible and precise errors, and to keep the returned errors as stable as possible, full stability cannot be guaranteed.
Fields§
§span: Option<Range<usize>>
§kind: ParseErrorKind
Implementations§
source§impl ParseError
impl ParseError
Trait Implementations§
source§impl Clone for ParseError
impl Clone for ParseError
source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ParseError
impl Debug for ParseError
source§impl Display for ParseError
impl Display for ParseError
source§impl Error for ParseError
impl Error for ParseError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for ParseError
impl RefUnwindSafe for ParseError
impl Send for ParseError
impl Sync for ParseError
impl Unpin for ParseError
impl UnwindSafe for ParseError
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)