()
| 1 | fn main() { |
| 2 | |
| 3 | // scope |
| 4 | // This binding lives in the main function |
| 5 | let long_lived_binding = 1; |
| 6 | |
| 7 | // This is a block, and has a smaller scope than the main function |
| 8 | { |
| 9 | // This binding only exists in this block |
| 10 | let short_lived_binding = 2; |
| 11 | |
| 12 | println!("inner short: {}", short_lived_binding); |
| 13 | |
| 14 | // This binding *shadows* the outer one |
| 15 | let long_lived_binding = 5_f32; |
| 16 | |
| 17 | println!("inner long: {}", long_lived_binding); |
| 18 | } |
| 19 | // End of the block |
| 20 | |
| 21 | // Error! `short_lived_binding` doesn't exist in this scope |
| 22 | println!("outer short: {}", short_lived_binding); |
| 23 | |
| 24 | println!("outer long: {}", long_lived_binding); |
| 25 | |
| 26 | // This binding also *shadows* the previous binding |
| 27 | let long_lived_binding = 'a'; |
| 28 | |
| 29 | println!("outer long: {}", long_lived_binding); |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected