What this Rust scope and ownership question tests
This is a medium-difficulty question that probes your understanding of Rust's scope and variable shadowing semantics. It asks you to trace through a code snippet and predict its output—a core skill for writing correct Rust in interview settings and in production quant codebases.
To solve problems like this, you need to track how variable bindings are introduced, reassigned, and shadowed within nested scopes. Rust's scoping rules interact subtly with ownership and borrowing, and interviewers use these questions to verify that you can reason about what the compiler sees, not just what your intuition suggests.
- Variable shadowing and scope boundaries
- Binding lifetime and visibility
- How nested blocks affect name resolution