This is something that I noticed by accident that might be useful, so, I figured that I'd gauge people's thoughts here.
Essentially, one thing that I've done in multiple crates before is have a type MyUnit = uN;
to make it a bit easier to potentially change N
later in the design process. It's also just helpful to be able to put into signatures what the "units" of something are without having to resort to newtypes.
One thing where this fails, however, is #[repr(uN)]
. It would be nice if we could do #[repr(MyUnit)]
here, resolving type aliases in this attribute.
Of course, this would complicate the language and potentially allow for shadowing (for example, what if you nefariously do type u8 = u32;
) and thus would be worth considering those as well.
The reason why I discovered it by accident is by doing a find-and-replace for u8
in a crate and accidentally included repr
as well. But, why can't we do this in repr?