Learning Rust - Common Programming Concepts
Based on “The Rust Programming” Variables and Mutability Constant are like immutable varibles, but always immutable. declare constants using the const keyword, and the type of the value must be annotated. constants can be declared in any scope, including the global scope. constants may be set only to a constant expression, not the result of a value that could only be computed at runtime. Rust’s naming convention for constants is to use all uppercase with underscores between words, such as THREE_HOURS_IN_SECONDS the compiler is able to evaluate a limited set of operations at compile time, which lets us choose to write out this value in a way that’s easier to understand and verify Shadow is different from a variable marked as mut will get a compile-time error if we accidentally try to reassign to this variable without using the let keyword....