Rust Quiz
Explain ownership, borrowing and errors rather than memorising keywords.
How it works
Consider four claims: moving String makes a deep copy; a shared reference transfers ownership; Result can represent an explained failure; a successful compile proves the application’s business rule. Decide which are true and state a reason. The answer key below is original teaching material, and executing it checks the key’s construction rather than proving every concept through one Boolean array.
Run the code
Reviewed with Rust 1.97.0, edition 2024, using the standard library only. Save the complete download as lesson-name.rs in a separate learning folder, compile with rustc --edition=2024 lesson-name.rs and run the resulting program (lesson-name.exe on Windows). Use the actual lesson filename. The final project includes complete Cargo package files; run cargo test --offline and cargo run --offline from that separate package folder. There is no Rust browser runner; PHP, Apache and MySQL are not needed.
This complete example was executed in the stated local review environment.
Example
fn main() {
let answers = [false, false, true, false];
assert_eq!(answers.iter().filter(|&&answer| answer).count(),1);
println!("Move is not deep copy; borrow is not ownership transfer; Result carries errors; compile is not business proof");
}
Expected result
Move is not deep copy; borrow is not ownership transfer; Result carries errors; compile is not business proof
A move transfers responsibility for an owned value, while a borrow supplies temporary access. Result’s error value can support a caller’s refusal policy. Compile checks cannot know whether the right seed quantity or permission rule was chosen. The negative compiler tests and numerical tests in the review provide separate evidence for those different contracts.
Primary technical reference: Rust documentation.