pub enum ArithmeticOperator {
Add,
Subtract,
Multiply,
Divide,
Modulo,
ModuloWord,
Increment,
Decrement,
}Expand description
An arithmetic operator.
Two behaviors differ from what the spelling suggests, both measured on a live engine:
- Division always produces a real number.
7/2is3.5, never3. There is no integer division operator. - The remainder takes the sign of the left operand.
-7 % 3is-1. That is truncated remainder, not the floored modulo some languages use, so a negative operand does not wrap into the positive range.
There is no exponentiation operator; ^ belongs to the bitwise family.
Variants§
Add
Addition, +.
Subtract
Subtraction, or negation when applied to one operand, -.
Multiply
Multiplication, *.
Divide
Division, /. Always real-valued.
Modulo
Remainder, %.
ModuloWord
Remainder, MOD, the word spelling of Self::Modulo.
Increment
Increment, ++.
Decrement
Decrement, --.
Implementations§
Source§impl ArithmeticOperator
impl ArithmeticOperator
Sourcepub const fn precedence(self) -> u8
pub const fn precedence(self) -> u8
Binding strength; lower binds tighter. Measured, see super.
Sourcepub const fn alternate_spelling(self) -> Option<Self>
pub const fn alternate_spelling(self) -> Option<Self>
The other spelling, for the operator that has one.
Trait Implementations§
Source§impl Clone for ArithmeticOperator
impl Clone for ArithmeticOperator
Source§fn clone(&self) -> ArithmeticOperator
fn clone(&self) -> ArithmeticOperator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ArithmeticOperator
Source§impl Debug for ArithmeticOperator
impl Debug for ArithmeticOperator
impl Eq for ArithmeticOperator
Source§impl Hash for ArithmeticOperator
impl Hash for ArithmeticOperator
Source§impl PartialEq for ArithmeticOperator
impl PartialEq for ArithmeticOperator
impl StructuralPartialEq for ArithmeticOperator
Auto Trait Implementations§
impl Freeze for ArithmeticOperator
impl RefUnwindSafe for ArithmeticOperator
impl Send for ArithmeticOperator
impl Sync for ArithmeticOperator
impl Unpin for ArithmeticOperator
impl UnsafeUnpin for ArithmeticOperator
impl UnwindSafe for ArithmeticOperator
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