Fields in Traits

It also effectively prevents enums from implementing the trait. I’d like to see some way to weasel oneself out from the necessity of a there to be an actual backing field – even if it were unsafe: one could override the “fieldness” with an unsafe implicitly called method that returned a reference to a memory location, and the unsafe code promises not to have side-effects and that the memory location is disjunct from other memory locations provided by the other fields. Of course this is just a strawman idea, and one with quite a lot of downsides…

4 Likes