What happens?
let s1 = String::from("hi");let s2 = s1;println!("{s1}");What this Rust test measures, in short
This test checks whether you can predict what the Rust compiler will accept and what the program will do: who owns a value, when it moves, how many borrows are allowed, how match and Option work, and how traits and the ? operator fit together.
Snippets assume Rust 2021 edition, inside fn main unless shown. The questions are our own and not standardised against a population, so treat the result as a check on your knowledge, not a certification.
By What's Your IQ · Reviewed 4 Oct 2026- Format
- 15 questions: output or compile error, 4 options
- Topics
- Ownership, borrowing, matching and Option, traits, errors and iterators
- Edition
- Rust 2021, stable compiler
- Language
- Started by Graydon Hoare; Mozilla-backed; 1.0 in 2015
Who owns the String right now?
Every value has exactly one owner. Moving transfers it, borrowing lends it out, and when the owner goes out of scope the value is dropped. Step through to see the compiler's view.
Compiles, but fights the language
fn port() -> u16 { let s = std::env::var("PORT").unwrap(); s.parse().unwrap()}fn port() -> Result<u16, Box<dyn Error>> { let s = std::env::var("PORT")?; Ok(s.parse()?)}unwrap turns every missing value or bad input into a crash. Returning Result with ? lets the caller decide what to do, and the signature tells everyone the function can fail.
- The Rust Team. (2015). Announcing Rust 1.0. Rust Blog.
- Miller, M. (2019). Trends, challenges, and strategic shifts in the software vulnerability mitigation landscape. Microsoft, BlueHat IL.
- The Chromium Projects. (2020). Memory safety.
- Corbet, J. (2022). Rust in the 6.1 kernel. LWN.net.