Medium
A match over an enum that omits one variant
Does this program compile?
main.rs
enum Shape {
Circle(f64),
Square(f64),
Triangle(f64, f64),
}
fn area(s: &Shape) -> f64 {
match s {
Shape::Circle(r) => std::f64::consts::PI * r * r,
Shape::Square(side) => side * side,
}
}
fn main() {
let c = Shape::Circle(2.0);
println!("{}", area(&c));
}43 of 53 in Rust