enum Shape { Circle(f64), Rect { w: f64, h: f64 }, } fn area(s: &Shape) -> f64 { match s { Shape::Circle(r) => std::f64::consts::PI * r * r, Shape::Rect { w, h } => w * h, } } fn size(n: u32) -> &'static str { match n { 0 => "none", 1..=9 => "a few", _ => "lots", } } fn main() { println!("{:.2}", area(&Shape::Circle(1.5))); println!("{}", area(&Shape::Rect { w: 2.0, h: 3.0 })); println!("{}", size(12)); }