Appearance
变量默认不可变,添加 mut 使其可变。
mut
let x = 1; let mut y = 123;
常量永远不可变。
const LIGHT_SPEED = 300000000;
let x = 5; let x = x + 1; { let x = x * 2; println!("x in scope: {x}") } println!("outer x : {x}")
$ cargo run x in scope: 12 outer x : 6