I know that Traits do not allow fields or properties, and I even understand why (after reading some of the discussions). And, I like the restriction, generally.
Traits can also have default implementations. This is great.
So, given these constraints, is there an idiomatic way to have that default implementation require that the implementing struct have a specific field? For example, with setters and/or getters?
I have about 50 “definition” structs, each with different combinations of the same 10 properties. They all have
description for example. I have created traits for some of the combinations like
HasDataTypes, which define the appropriate setters and getters, but each implementer still has to have those fields.
It would be nice to direct the implementor that they must have certain fields.
Am I missing something? Is there a more rust-ish way of doing this?