Variables and Mutability
Variables are immutable by default. Add mut to change them. const needs a type and a constant value.
Example
fn main() {
let x = 5;
let mut y = 1;
y += x;
const MAX: u32 = 100;
println!("{} {} {}", x, y, MAX);
}Result
5 6 100
Exercise
Make it changeable.
let n = 1;
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.