← Back to archive

Stdle #167 · classes · 2026-11-20

What does this Rust snippet output?

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

trait Greet {
fn name(&self) -> String;
fn hello(&self) -> String {
format!("Hi, {}", self.name())
}
}
struct A;
impl Greet for A {
fn name(&self) -> String { "A".into() }
}
fn main() {
println!("{}", A.hello());
}
Classes
4 attempts left

Answer & explanation