← Back to archive

Stdle #173 · classes · 2026-11-26

What does this Rust snippet output?

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

trait Speak {
fn word(&self) -> &str { "default" }
}
struct Dog;
impl Speak for Dog {
fn word(&self) -> &str { "woof" }
}
struct Cat;
impl Speak for Cat {}
fn main() {
println!("{} {}", Dog.word(), Cat.word());
}
Classes
4 attempts left

Answer & explanation