初級 › E0384: cannot assign twice to immutable variable の原因と直し方 › パターン2
E0384: cannot assign twice to immutable variable の原因と直し方
Rustの変数はデフォルトで不変(immutable)です。
1 fn main() { 2 let _______score = 10; ^ 3 score = 20; 4 println!("{}", score); 5 }
error[E0384]: cannot assign twice to immutable variable `score`
空欄を埋めて実行を通す
mutが無い変数への再代入はコンパイル時に検出されます。実行するまでもなくエラーになります。
次の問題