Understanding Rust function calls and variable scope
This is a medium-difficulty Rust question that tests whether you can trace code execution carefully, paying close attention to how function calls work, what values get bound to variables, and what actually executes in a given order. It rewards precise mental execution over guessing.
To work through problems like this, read the code linearly, track which expressions are evaluated and in what order, and note which statements actually run versus which are merely defined. Pay special attention to function invocations, return values, and any side effects—printing, mutations, or panics—that happen as the code flows.
- Function call semantics and argument evaluation
- Variable binding and shadowing
- Control flow and conditional execution
- Standard output and side effects