Test yourself under real exam conditions: 50 timed questions, 60 on the clock, pass mark 70%%. Instant score with a full review of everything you got wrong. Free — no account needed.
Exam details
Each value in Rust has an owner. There can only be one owner at a time. When the owner goes out of scope, the value is dropped.
It is dropped — its drop function runs and its memory is freed.
drop, from the Drop trait, is called automatically at the end of the variable's scope.
A transfer of ownership: assigning a value to another variable or passing it to a function moves the value, invalidating the source binding.
Moving avoids double-free bugs and keeps the type system simple — for stack-allocated types that own heap data (like String), copying the pointer would leave two owners.