Rust Variables
In this post, we will learn some important fact about variable of a rust programming language.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
In this post, we will learn some important fact about variable of a rust programming language.
Point to Remember
1. Rust variables can be type annotated
2. Default Rust variable is immutable so we can not change its value
3. Mutable variable value can be changed
4. Type of Rust variable can not be changed
5. Rust variables can be overwritten with shadowing let logical: bool = true;
let logical: bool = true;
// Error
logical = false;
let mut logical: bool = true;
// valid
logical = false;
let mut mutable = 5;
// Error
mutable = true;
let mut mutable = 5;
// valid
let mutable = true;
Comments
Post a Comment