Enum — sum type, variants. Struct — product type, fields.
Enum:
Struct:
1// Enum2enum Shape {3 Circle(f64),4 Rectangle(f64, f64),5}67// Struct8struct Circle {9 radius: f64,10}
Pattern matching with enum:
1match shape {2 Shape::Circle(r) => println!("Circle: {}", r),3 Shape::Rectangle(w, h) => println!("Rect: {}x{}", w, h),4}
Key: Enum for variants, Struct for records.