9 ms·
AFAIK there is no prescriptive standard for Rust, there's only descriptions of how the rustc compiler works. But this was a very intentional decision quite some
by eridius 7y ago
AFAIK there is no prescriptive standard for Rust, there's only descriptions of how the rustc compiler works. But this was a very intentional decision quite some time ago, and is also the reason why the `std::ptr::NonNull` type exists (the documentation explicitly states this allows enums to use the forbidden value as a discriminant).
FWIW the module documentation of `std::option` does describe this optimization for Option<Box<T>>.
> This usage of Option to create safe nullable pointers is so common that Rust does special optimizations to make the representation of Option<Box<T>> a single pointer. Optional pointers in Rust are stored as efficiently as any other pointer type.