pub enum ArithError {
Show 14 variants
InvalidNumericConstant,
InvalidCharacter,
IncompleteExpression,
MissingOperator,
UnclosedParenthesis {
opening_location: Location,
},
QuestionWithoutColon {
question_location: Location,
},
ColonWithoutQuestion,
InvalidOperator,
InvalidVariableValue(String),
Overflow,
DivisionByZero,
LeftShiftingNegative,
ReverseShifting,
AssignmentToValue,
}Expand description
Types of errors that may occur in arithmetic expansion
This enum is essentially equivalent to yash_arith::ErrorCause. The
differences between the two are:
ArithErrordefines all error variants flatly whileErrorCausehas nested variants.ArithErrormay contain informativeLocationthat can be used to produce an error message with annotated code whileErrorCausemay just specify a location as an index range.
Variants§
InvalidNumericConstant
A value token contains an invalid character.
InvalidCharacter
An expression contains a character that is not a whitespace, number, or number.
IncompleteExpression
Expression with a missing value
MissingOperator
Operator missing
UnclosedParenthesis
( without )
QuestionWithoutColon
? without :
ColonWithoutQuestion
: without ?
InvalidOperator
Other error in operator usage
InvalidVariableValue(String)
A variable value that is not a valid number
Overflow
Result out of bounds
DivisionByZero
Division by zero
LeftShiftingNegative
Left bit-shifting of a negative value
ReverseShifting
Bit-shifting with a negative right-hand-side operand
AssignmentToValue
Assignment with a left-hand-side operand not being a variable
Implementations§
Source§impl ArithError
impl ArithError
Returns a location related with this error and a message describing the location.
Trait Implementations§
Source§impl Clone for ArithError
impl Clone for ArithError
Source§fn clone(&self) -> ArithError
fn clone(&self) -> ArithError
Returns a duplicate 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 ArithError
impl Debug for ArithError
Source§impl Display for ArithError
impl Display for ArithError
Source§impl Error for ArithError
impl Error for ArithError
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()
Source§impl From<ArithError> for ErrorCause
impl From<ArithError> for ErrorCause
Source§fn from(source: ArithError) -> Self
fn from(source: ArithError) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ArithError
impl PartialEq for ArithError
impl Eq for ArithError
impl StructuralPartialEq for ArithError
Auto Trait Implementations§
impl Freeze for ArithError
impl !RefUnwindSafe for ArithError
impl !Send for ArithError
impl !Sync for ArithError
impl Unpin for ArithError
impl !UnwindSafe for ArithError
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more