Understanding ownership and borrowing in Rust
This is an easy Rust question that tests your grasp of ownership semantics — one of the language's most distinctive features. Interviewers and technical screens use questions like this to confirm you understand how Rust tracks which part of a program has the right to use, modify, or free a value.
To answer correctly, you need to trace through variable bindings, moves, and borrows as they happen in sequence. Pay attention to when ownership transfers to a function, when a reference is created, and what scope each binding has. The output will depend on whether values are moved, borrowed immutably, or borrowed mutably — and what remains accessible afterward.
- Move semantics vs. copy semantics
- Immutable and mutable borrows
- Scope and the borrow checker rules