For my fellow Rust enthusiasts, it is well-known that the compiler is able to perform some optimizations, called “niche”, that can make, for example, an Option<NonZeroU32>
fits on 32-bits. In this article, I will try to understand how it extends to some other enum types, and how the compiler achieves this.