Document that casting &mut T to &mut MaybeUninit<T> is not safe #66699
Closed
Description
As discussed on Reddit, it turns out that casting &mut T
to &mut MaybeUninit<T>
is not a safe operation, since it allows UB in safe code.
Playground example demonstrating the UB: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=93dd41cf851bfc0de2233e0a83b4b778
It is probably a good idea to explicitly point that out in MaybeUninit docs.