As asked
Walk me through what happens to a value's ownership when you pass it to a function, and how that differs from languages with garbage collectors. Where exactly does the compiler insert the drop?
Sample answer outline
Strong answer covers the single-owner rule, that passing by value moves ownership into the callee's stack frame, and that the compiler inserts a drop at the end of the owning scope. Candidate should contrast this with GC languages where the runtime tracks reachability at runtime and reclaim asynchronously, noting Rust guarantees zero-cost deterministic cleanup.
Expect these follow-ups
- What happens if you pass a type that implements Copy instead of moving it?
- How does the compiler prove at compile time that a moved value is never used again?