blob: e21fac0797cb98e25aaa2cf71bd6485ed0e8c8d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
An immutable variable was reassigned.
Erroneous code example:
```compile_fail,E0384
fn main() {
let x = 3;
x = 5; // error, reassignment of immutable variable
}
```
By 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;
}
```
|