pub enum AssignOp {
Show 16 variants
Assign,
Add,
Sub,
Mul,
Div,
Mod,
Exp,
And,
Or,
Xor,
Shl,
Shr,
Ushr,
BoolAnd,
BoolOr,
Coalesce,
}
Expand description
An assignment operator assigns a value to its left operand based on the value of its right operand.
The simple assignment operator is equal (=
), which assigns the value of its right operand to its
left operand. That is, x = y
assigns the value of y to x
.
There are also compound assignment operators that are shorthand for the operations
More information:
Variants§
Assign
The assignment operator assigns the value of the right operand to the left operand.
Syntax: x = y
More information:
Add
The addition assignment operator adds the value of the right operand to a variable and assigns the result to the variable.
Syntax: x += y
The types of the two operands determine the behavior of the addition assignment operator. Addition or concatenation is possible.
More information:
Sub
The subtraction assignment operator subtracts the value of the right operand from a variable and assigns the result to the variable.
Syntax: x -= y
More information:
Mul
The multiplication assignment operator multiplies a variable by the value of the right operand and assigns the result to the variable.
Syntax: x *= y
More information:
Div
The division assignment operator divides a variable by the value of the right operand and assigns the result to the variable.
Syntax: x /= y
More information:
Mod
The remainder assignment operator divides a variable by the value of the right operand and assigns the remainder to the variable.
Syntax: x %= y
More information:
Exp
The exponentiation assignment operator raises the value of a variable to the power of the right operand.
Syntax: x ** y
More information:
And
The bitwise AND assignment operator uses the binary representation of both operands, does a bitwise AND operation on them and assigns the result to the variable.
Syntax: x &= y
More information:
Or
The bitwise OR assignment operator uses the binary representation of both operands, does a bitwise OR operation on them and assigns the result to the variable.
Syntax: x |= y
More information:
Xor
The bitwise XOR assignment operator uses the binary representation of both operands, does a bitwise XOR operation on them and assigns the result to the variable.
Syntax: x ^= y
More information:
Shl
The left shift assignment operator moves the specified amount of bits to the left and assigns the result to the variable.
Syntax: x <<= y
More information:
Shr
The right shift assignment operator moves the specified amount of bits to the right and assigns the result to the variable.
Syntax: x >>= y
More information:
Ushr
The unsigned right shift assignment operator moves the specified amount of bits to the right and assigns the result to the variable.
Syntax: x >>>= y
More information:
BoolAnd
The logical and assignment operator only assigns if the target variable is truthy.
Syntax: x &&= y
More information:
BoolOr
The logical or assignment operator only assigns if the target variable is falsy.
Syntax: x ||= y
More information:
Coalesce
The logical nullish assignment operator only assigns if the target variable is nullish (null or undefined).
Syntax: x ??= y
More information:
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for AssignOp
impl<'arbitrary> Arbitrary<'arbitrary> for AssignOp
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for AssignOp
impl<'de> Deserialize<'de> for AssignOp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl TryFrom<Punctuator> for AssignOp
impl TryFrom<Punctuator> for AssignOp
impl Copy for AssignOp
impl Eq for AssignOp
impl StructuralPartialEq for AssignOp
Auto Trait Implementations§
impl Freeze for AssignOp
impl RefUnwindSafe for AssignOp
impl Send for AssignOp
impl Sync for AssignOp
impl Unpin for AssignOp
impl UnwindSafe for AssignOp
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.