An immutable variable was reassigned.
Erroneous code example:
fn main() {
let x = 3;
x = 5; // error, reassignment of immutable variable
}
RunBy default, variables in Rust are immutable. To fix this error, add the keyword
mut
after the keyword let
when declaring the variable. For example:
fn main() {
let mut x = 3;
x = 5;
}
Run