An example is how Option<Box<T>> optimises down to a single pointer in Rust — the compiler uses its knowledge of how Box<T> is non-nullable, and coopts the null value to represent the None value for the Option.
An example is how Option<Box<T>> optimises down to a single pointer in Rust — the compiler uses its knowledge of how Box<T> is non-nullable, and coopts the null value to represent the None value for the Option.
So, in this case, it's a documented part of Option.
I realize this answer isn't fantastic, but it's where we're at now. It's why we're working on the reference this year!
I didn't know this, it's good to hear. Thanks!
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.