my practice for learning rust
- rustup
- rustc
- cargo
- Let x: i32 = 5; or let x = 5; x is i32
- Let mut x: i32 = 5; or let mut x = 5; x is i32
fn variables_shadowing() {
let x = 5;
let x = x + 1;
let x = x * 2;
println!("The value of x is: {}", x);
// The value of x is: 12
}
fn variables_shadowing() {
let x = 5;
let y = x + 1;
let z = y * 2;
println!("The value of z is: {}", z);
// The value of z is: 12
}
1. The shadowing can change datatype, but mutable can't.
2. The shadowing is alway immutable.
- Snake Case: Let _nice_count : i32 = 0;
- Pascal Case(For enumerate and structure)
Let __nice_count_one : i32 = 0;
Let _nice_count_two = __nice_count_one as i32;
println!("Value is: {}", __nice_count_one);
println!("Value is: {__nice_count_one}");