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 Clone for AssignOp

source§

fn clone(&self) -> AssignOp

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AssignOp

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for AssignOp

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for AssignOp

source§

fn eq(&self, other: &AssignOp) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl TryFrom<Punctuator> for AssignOp

§

type Error = String

The type returned in the event of a conversion error.
source§

fn try_from(punct: Punctuator) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for AssignOp

source§

impl Eq for AssignOp

source§

impl StructuralPartialEq for AssignOp

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.