]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0384.md
Auto merge of #66396 - smmalis37:pythontest, r=alexcrichton
[rust.git] / src / librustc_error_codes / error_codes / E0384.md
1 This error occurs when an attempt is made to reassign an immutable variable.
2
3 Erroneous code example:
4
5 ```compile_fail,E0384
6 fn main() {
7     let x = 3;
8     x = 5; // error, reassignment of immutable variable
9 }
10 ```
11
12 By default, variables in Rust are immutable. To fix this error, add the keyword
13 `mut` after the keyword `let` when declaring the variable. For example:
14
15 ```
16 fn main() {
17     let mut x = 3;
18     x = 5;
19 }
20 ```