#[non_exhaustive]pub enum ArithError {
Show 16 variants
InvalidNumericConstant,
InvalidCharacter,
IncompleteExpression,
MissingOperator,
UnclosedParenthesis {
opening_location: Location,
},
QuestionWithoutColon {
question_location: Location,
},
ColonWithoutQuestion,
InvalidOperator,
NonPortableIncrementDecrement,
InvalidVariableValue(String),
Overflow,
DivisionByZero,
LeftShiftingNegative,
ReverseShifting,
AssignmentToValue,
Unrecognized(String),
}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 (Non-exhaustive)§
This enum is marked as non-exhaustive
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
NonPortableIncrementDecrement
An increment or decrement operator is used while the portable option
is on.
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
Unrecognized(String)
An arithmetic error not recognized by this crate
This variant is used to wrap an error cause that is returned by future
versions of yash_arith but not yet recognized by this crate. The
associated string is the Display representation of the error cause.
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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ArithError
impl Debug for ArithError
Source§impl Display for ArithError
impl Display for ArithError
impl Eq 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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
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
Source§impl PartialEq for ArithError
impl PartialEq for ArithError
impl StructuralPartialEq for ArithError
Auto Trait Implementations§
impl !RefUnwindSafe for ArithError
impl !Send for ArithError
impl !Sync for ArithError
impl !UnwindSafe for ArithError
impl Freeze for ArithError
impl Unpin for ArithError
impl UnsafeUnpin 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
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>
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>
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