Rust by Example: Variables
In Rust, variables provide explicit type information, aiding in type safety checks by the compiler. Here, we demonstrate variable mutability, reassignment, type inference, and explicit type declaration. Additionally, Rust allows variable shadowing, enabling the redeclaration of a variable with a different type. |
|
|
|
By default, variables are immutable |
|
To make a variable mutable, use the |
|
Variables can be reassigned |
|
Types can be inferred |
|
Or types can be explicitly declared |
|
Variables can be shadowed, the variable |
|
|