During work on a side project I\'ve tried to use an increment operator, as following:
fn main() {
let mut my_var = 5;
my_var++;
}
a
Increment (++) and decrement (--) operators are not supported in Rust.
From Rust's FAQ:
Why doesn't Rust have increment and decrement operators?
Preincrement and postincrement (and the decrement equivalents), while convenient, are also fairly complex. They require knowledge of evaluation order, and often lead to subtle bugs and undefined behavior in C and C++.x = x + 1
orx += 1
is only slightly longer, but unambiguous.