面试题答案
一键面试fn process_shapes(shapes: Vec<Box<dyn Shape>>) {
for shape in shapes {
match shape.as_ref() {
Circle { radius } => println!("Circle, Area: {}", std::f64::consts::PI * radius * radius),
Rectangle { width, height } => println!("Rectangle, Area: {}", width * height),
}
}
}