#[derive(Debug)] enum Shape { Circle { r: f64 }, Rect { w: f64, h: f64 }, Dot } fn name(s: &Shape) -> &'static str { match s { Shape::Circle { .. } => "circle", Shape::Rect { w, h } => if w == h { "square" } else { "rectangle" }, _ => "other", } } fn main() { assert_eq!(name(&Shape::Circle {r:1.0}),"circle");assert_eq!(name(&Shape::Rect {w:2.0,h:2.0}),"square");assert_eq!(name(&Shape::Rect {w:2.0,h:3.0}),"rectangle");assert_eq!(name(&Shape::Dot),"other"); }