RsRust · Lesson 2 of 8
Variables & Types
In Rust, variables are immutable by default. This is not a bug. This is the entire point.
Use let to declare variables. They are immutable by default — you cannot change them after assignment. Use let mut if you need mutability. Rust infers types, but you can annotate them explicitly.
Shadowing is a Rust superpower: you can re-declare a variable with the same name using let, even changing its type. This is different from mutation.
⚠ Warning
Integer overflow panics in debug mode and wraps silently in release mode. Use checked_add(), saturating_add(), or wrapping_add() when you need explicit overflow behavior.
Integer overflow panics in debug mode and wraps silently in release mode. Use checked_add(), saturating_add(), or wrapping_add() when you need explicit overflow behavior.