5 ms·
A clarification: Rust only makes this guarantee for certain types[1] which you would expect to be represented by a simple pointer under the hood (e.g., Box<U>,
by CodeIsTheEnd 5y ago
A clarification: Rust only makes this guarantee for certain types[1] which you would expect to be represented by a simple pointer under the hood (e.g., Box<U>, &T, function pointers) and for other types which can never be all 0.
Making this optimization for something like Option<u8> is, naturally, impossible.
(I assume you are aware of this and were implicitly referring to this optimization.)
[1]: https://doc.rust-lang.org/std/option/#representation https://doc.rust-lang.org/std/option/#representation