let — variable binding (can be mutable). const — compile-time constant (always immutable).
let:
let mut for mutability.1let x = 5;2let mut y = 10;3y += 5;45let (name, age) = ("Alice", 30);6let Point { x, y } = point;
const:
1const MAX: u32 = 100_000;2const PI: f64 = 3.14159265358979;3const COLORS: [u8; 3] = [255, 128, 0];45const fn add(a: i32, b: i32) -> i32 { a + b }6const RESULT: i32 = add(10, 20); // 30
When to use:
const for configuration values.let for general variables.static for global values.Common mistakes:
const — required.const at runtime.const and static.