How to avoid code duplication of different structs with semantically equal fields/properties?
This looks like a perfect case for generics. You can make a single struct like this: struct ShapeRenderer<T: Shape> { canvas: Canvas, origin: Point, shape: T, } Note that I have bounded the generic type T by a trait Shape (that you would have to create). You can put any bounds here you like (or … Read more