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.
0b64can 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: ParseErrorKindImplementations§
Source§impl ParseError
impl ParseError
Sourcepub fn span(&self) -> Option<Range<usize>>
pub fn span(&self) -> Option<Range<usize>>
Returns a span of this error, if available. Note: the returned span might change in future versions of this library. See the documentation of this type for more information.
Sourcepub(crate) fn offset_span(self, offset: usize) -> Self
pub(crate) fn offset_span(self, offset: usize) -> Self
Adds offset to the start and endpoint of the inner span.
Trait Implementations§
Source§impl Clone for ParseError
impl Clone for ParseError
Source§fn clone(&self) -> ParseError
fn clone(&self) -> ParseError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more