Rust TutorialLesson 7Free preview
Rust Variables
This lesson is part of Rust · All levels
Summary
This lesson discusses the declaration of variables and the concept of mutability in Rust. By default, all variables in Rust are immutable (unchangeable) to prevent an unintended state change. If the value is to be changed, the programmer must explicitly add the keyword 'mut'.
Key points
- Variable declared with the keyword 'let'
- By default the variable in Rust is immutable
- The keyword 'mut' must be added if the variable needs to be changed in value
- The shadowing concept allows the re-declaration of the variable with the same name
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.