Variable Scope in Rust
- Every block creates a scope
examples/other/scope/src/main.rs
fn main() { let fname = "Foo"; let lname = "Bar"; println!("{} {}", fname, lname); { let fname = "Peti"; println!("{} {}", fname, lname); } println!("{} {}", fname, lname); }
Foo Bar Peti Bar Foo Bar