- let
Redeclare immutable variable - Shadowing
- You can actually change even an immutable variable by declaring it again.
- It can be useful if you need to make a few changes and then later no more changes.
examples/variables/shadow/src/main.rs
fn main() { let name = "Foo"; println!("{name}"); let name = "Bar"; println!("{name}"); }
Foo Bar