1enum Shape { 2 Circle(f64), 3 Rectangle(f64, f64), 4} 5 6fn area(shape: Shape) -> f64 { 7 match shape { 8 Shape::Circle(r) => std::f64::consts::PI * r * r, 9 Shape::Rectangle(w, h) => w * h, 10 } 11}
Rich enums with data and exhaustive pattern matching.