面试题答案
一键面试enum Shape {
Circle(f64),
Rectangle(f64, f64),
Triangle(f64, f64)
}
fn calculate_area(s: Shape) -> f64 {
match s {
Shape::Circle(radius) => 3.14 * radius * radius,
Shape::Rectangle(length, width) => length * width,
Shape::Triangle(base, height) => 0.5 * base * height
}
}