Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Inheritance was invented as a performance hack. Parent comment
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 {...}
There are no comments on this comment yet.
You can also do this:
Or this (although this is the least common):