Another Experiment To Make Unsafe Rust Safer: Preventing UB In MaybeUninit With Compile Time Error
Rust Internals [Unofficial]
May 22, 2026
In every program where it is possible to call your version of write(), which moves the "storage" and returns a new value of a different type, it is possible, and simpler, to not use MaybeUninit at all.
MaybeUninit is used in situations where
- the storage must not be moved, or
- the memory becomes initialized a piece at a time, not all at once (like the examples in
MaybeUninit's documentation: Initializing an array element-by-element and Initializing a struct field-by-field).
These things cannot be implemented using your write().
Discussion in the ATmosphere