初級 › E0384: cannot assign twice to immutable variable の原因と直し方 › パターン5
E0384: cannot assign twice to immutable variable の原因と直し方
Rustの変数はデフォルトで不変(immutable)です。
1 fn main() { 2 let _______age = 20; ^ 3 age = 21; 4 println!("{}", age); 5 }
error[E0384]: cannot assign twice to immutable variable `age`
空欄を埋めて実行を通す
不変性はRustの基本方針です。書き換える意図がある変数には必ずmutを付けます。
次の問題