You can also do this:
struct Vehicle { speed: f32, type: VehicleType } enum VehicleType { Car(...), Bicycle(...) }
struct Vehicle { data: VehicleData type: Box<dyn SpecificVehicle> } struct VehicleData { speed: f32, } trait SpecificVehicle { fn quack(&self, data: &VehicleData); } impl SpecificVehicle for Car {...} impl SpecificVehicle for Bicycle {...}
You can also do this:
Or this (although this is the least common):