Augmenting Assignment statement
Syntax
AssignmentStatement :
Expression=
Expression
| Expression+=
Expression
| Expression-=
Expression
| Expression%=
Expression
| Expression**=
Expression
| Expression<<=
Expression
| Expression>>=
Expression
| Expression|=
Expression
| Expression^=
Expression
| Expression&=
Expression
Augmenting assignment statements combine arithmetic and logical binary operators with assignment statements.
An augmenting assignment statement consists of an expression that holds a mutable place, followed by one of the arithmetic or logical binary operators, followed by an equals sign (=) and a value expression.
Example:
fn example() -> u8 {
let mut a: u8 = 1
let b: u8 = 2
a += b
a -= b
a *= b
a /= b
a %= b
a **= b
a <<= b
a >>= b
a |= b
a ^= b
a &= b
return a
}