juniorRust

What is mutability in Rust?

Updated May 24, 2026

Short answer

Mutability determines whether a variable can be changed after assignment.

Deep explanation

Variables are immutable by default in Rust. The mut keyword explicitly allows modification, improving safety and predictability.

Real-world example

Counters, accumulators, and state updates in applications.

Common mistakes

  • Overusing mutability instead of leveraging immutable patterns.

Follow-up questions

  • Why are variables immutable by default?
  • Can references be mutable?

More Rust interview questions

View all →