← Back to archive

Stdle #107 · classes · 2026-09-21

What does this Rust snippet output?

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

struct Rect { w: u32, h: u32 }
impl Rect {
fn square(s: u32) -> Rect { Rect { w: s, h: s } }
fn area(&self) -> u32 { self.w * self.h }
}
fn main() {
let r = Rect::square(4);
println!("{}", r.area());
}
Classes
4 attempts left

Answer & explanation