← Rust Programming learning pathRust Programming · Module 2 of 10
Variables, types and functions
Learn Rust syntax for values and functions.
📖 Key ideas
- Variables are immutable by default: let x = 5;
- Use let mut for mutable variables.
- Types: i32, u64, f64, bool, char, String, &str.
- Functions: fn add(a: i32, b: i32) -> i32 { a + b }.
- The last expression without ; is the return value.
💡 Real-life example: Immutable by default is like writing in pen: you must choose a pencil (mut) to make changes.
letDeclares a variable
mutMakes a variable mutable
i3232-bit signed integer
-> Function return type