Is there a discussion on something like "strong type aliases" in @rustlang?
What I mean, simplified, is something like this:
strong type Width = u32;
strong type Height = u32;
Where it would differ from type aliases i that you cannot pass a Height as an argument declared as Width
-
-
I saw that pattern. It seems though that reimplemeting all traits for more complex types can be a bit tedious? In the u32 case, the memory layout would be the same (?) but I would have to reimplement Clone right?
-
Yes, the memory layout would be the same. It’s a completely distinct type, so yeah, you have to implement traits again. Clone is easy since it can be derived, others would be more complex.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.