2 ms·
That is called “niche optimization” and the compiler will in fact still do it for a hand-rolled Option type.
by School-Cotton 5y ago
That is called “niche optimization” and the compiler will in fact still do it for a hand-rolled Option type.
- herbstein 5y agoFor anyone not sure, here is the proof. https://godbolt.org/z/4zhWM9hTP https://godbolt.org/z/4zhWM9hTP
- tialaramex 5y agoAlthough, Rust only knows about certain obvious niches. It can reason that it can fit None in the same space as NonZeroU64 or a reference &T but it doesn't see how to do this with a hypothetical EvenU64 as I understand it because that "niche" is in the wrong place.