Where can I find authoritative documentation on Rust's null pointer optimization? I've found repr(Rust) - The Rustonomicon, which says:
The classic case of this is Rust's "null pointer optimization": an enum consisting of a single outer unit variant (e.g.
None) and a (potentially nested) non- nullable pointer variant (e.g.
Some(&T)) makes the tag unnecessary. A null pointer can safely be interpreted as the unit (
None) variant. The net result is that, for example,
size_of::<Option<&T>>() == size_of::<&T>().
But that seems like an aside rather than the official documentation of this feature. Is this officially documented somewhere?
I was in particular trying to figure out whether the optimization applies also to