- +=
- ++
- --
Increment integers - augmented assignment
- Instead of x = x + 1 we can use x += 1 called augmented assignment.
- There are no prefix and postfix increment and decrement operators.
examples/numbers/increment/src/main.rs
#[allow(clippy::assign_op_pattern)] fn main() { let mut x = 1; println!("{x}"); x = x + 1; println!("{x}"); x += 1; println!("{x}"); // Rust has no prefix and postfix increment operator // x++; // ++x; }
1 2 3