Rust TutorialLesson 9Free preview
Rust Constants
This lesson is part of Rust · All levels
Summary
This lesson explains the use of constants on Rust using the keyword 'const'. The constant is always fixed, its value must be a compile-time constant, and its data type must be explicitly declared. Understanding constants helps developers distinguish fixed configuration values from ordinary immutable variables.
Key points
- A constant is declared with the keyword 'const', not 'let'
- The data type on the constant must be written explicitly
- The value of a constant must be compile-time expression
- Conventionally, the name of a constant is written using capital letters with a lower-line separator (SCREAMING_SNAKE_CASE)
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.