← Back to archive

Stdle #129 · option · 2026-10-13

What does this Rust snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

fn main() {
let opt = Some(3);
let res: Result<i32, &str> = opt.ok_or("none");
println!("{:?}", res);
let n: Option<i32> = None;
println!("{:?}", n.ok_or("none"));
}
Option
2 lines
4 attempts left

Answer & explanation