← Back to archive

Stdle #34 · classes · 2026-07-10

What does this Rust snippet output?

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

use std::fmt::Display;
fn show<T: Display>(x: T) -> String {
format!("[{}]", x)
}
fn main() {
println!("{}", show(42));
println!("{}", show('z'));
}
Classes
2 lines
4 attempts left

Answer & explanation