pub struct ScanError {
pub at: ScanErrorAt,
pub kind: ScanErrorKind,
/* private fields */
}
Expand description
Represents an error that occurred during scanning.
Depending on what happened, it could represent an actual scanning failure, a problem with the pattern, an underlying IO failure, or something else entirely.
Fields§
§at: ScanErrorAt
The rough cursor position at which this error occurred. This will typically be the position the input cursor was at when it began trying to scan a particular literal or value.
kind: ScanErrorKind
The kind of error that occurred.
Implementations§
Source§impl ScanError
impl ScanError
Sourcepub fn new(at: usize, kind: ScanErrorKind) -> Self
pub fn new(at: usize, kind: ScanErrorKind) -> Self
Construct a new ScanError
.
Sourcepub fn expected_end() -> Self
pub fn expected_end() -> Self
Shorthand for constructing an ExpectedEnd
error.
Sourcepub fn float(err: ParseFloatError) -> Self
pub fn float(err: ParseFloatError) -> Self
Shorthand for constructing an Float
error.
Sourcepub fn int(err: ParseIntError) -> Self
pub fn int(err: ParseIntError) -> Self
Shorthand for constructing an Int
error.
Sourcepub fn literal_mismatch() -> Self
pub fn literal_mismatch() -> Self
Shorthand for constructing a LiteralMismatch
error.
Sourcepub fn syntax_no_message() -> Self
pub fn syntax_no_message() -> Self
Shorthand for constructing a SyntaxNoMessage
error.
Sourcepub fn other<E: Into<Box<dyn Error>>>(err: E) -> Self
pub fn other<E: Into<Box<dyn Error>>>(err: E) -> Self
Shorthand for constructing an Other
error.
Sourcepub fn furthest_along(self, other: Self) -> Self
pub fn furthest_along(self, other: Self) -> Self
Compare two ScanError
s, and return the one which occurred the furthest into the input cursor.
Sourcepub fn add_offset(self, bytes: usize) -> Self
pub fn add_offset(self, bytes: usize) -> Self
Adds the given number of bytes
to the error’s position.
This is used where an error has been generated by trying to scan a subslice of the original input, and the position needs to be corrected.