Due to niche optimization, Rust will guarentee that the following types will all have the same layout in memory. However, each option comes with different guarentees and should be selected accordingly.
&T
&mut T
NonNull<T>
*mut T
, but non-zero and covariant
Box<T>
- Same aliasing rules as
&mut T