“`rust
let rate: f64 = 60.0; // immutable
let mut passed = 0; // mutable
for m in [78, 91, 45, 33] { if m >= 40 { passed += 1; } }
let amount = 12_u32 as f64 * rate;
println!(“{amount:.2}”);
“`
Immutability by default prevents accidental changes. Types: i32/u32 integers, f64 decimals, bool, &str (borrowed text) and String (owned, growable text).
💡 Let the compiler teach you: Rust’s error messages usually say exactly what to change.
Code for this course follows standard, current syntax; we test JavaScript and PowerShell scripts before publishing, and R/Java/Rust examples are kept to core language features. Tell us if anything fails on your setup.
Practice
Change a variable without mut and read the compiler message.