← Back to archive

Stdle #165 · closures · 2026-11-18

What does this Rust snippet output?

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

fn main() {
let s = String::from("hi");
let f = || println!("{}", s);
f();
println!("{}", s);
}
Closures
2 lines
4 attempts left

Answer & explanation