box-o-sand/rustbyexample/variable_bindings/scope2.rs

17 lines
383 B
Rust
Raw Normal View History

2021-10-06 23:40:31 +00:00
fn main() {
let shadowed_binding = 1;
{
println!("before being shadowed: {}", shadowed_binding);
let shadowed_binding = "abc";
println!("shadowed in inner block: {}", shadowed_binding);
}
println!("outside inner block: {}", shadowed_binding);
let shadowed_binding = 2;
println!("shadowed in outer block: {}", shadowed_binding);
}