Guarantee that it is sound to observe the bytes of None::<P>
where P
is a pointer type subject to NPO #117591
Open
Description
In #115333, we added a guarantee that transmuting from [u8; N]
to Option<P>
is sound where P
is a pointer type subject to the null pointer optimization (NPO). It would be useful to be able to guarantee the inverse - that if all of the bytes of P
are initialized, then all of the bytes of None::<P>
(and thus all of the bytes of any Option<P>
) are initialized. For example, this would allow zerocopy to support safe transmutation from Option<P>
to [u8; N]
(google/zerocopy#596).
I'm opening this issue first rather than a PR so there's an opportunity to discuss whether this is something we want, how it would be best to document it, etc.