Rustlings Arena

Pick up Rust in just 1 hour through mini challenges.
Don't overthink, just start now.

0 / 26 levels0%
25%50%75%100%

Variables & Mutability

1 / 26

Quick walkthrough

In Rust, every variable is immutable by default. Once you set a value, the compiler won't let you change it.

This code fails to compile:

let x = 5;
x = 10;
// ❌ error: cannot assign twice
//    to immutable variable `x`

The fix is adding mut right after let:

let mut x = 5;
x = 10;
// βœ… compiles fine!

The order is always let mut β€” never mut let. Two keywords, one space.