Rollup merge of #130214 - RalfJung:zeroed, r=Mark-Simulacrum
MaybeUninit::zeroed: mention that padding is not zeroed That should clarify cases like [this](https://github.com/rust-lang/rust/pull/129778#issuecomment-2342542847).
This commit is contained in:
commit
0648987532
@ -351,6 +351,9 @@ pub const fn uninit() -> MaybeUninit<T> {
|
|||||||
/// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not
|
/// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not
|
||||||
/// be null.
|
/// be null.
|
||||||
///
|
///
|
||||||
|
/// Note that if `T` has padding bytes, those bytes are *not* preserved when the
|
||||||
|
/// `MaybeUninit<T>` value is returned from this function, so those bytes will *not* be zeroed.
|
||||||
|
///
|
||||||
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
|
/// Note that dropping a `MaybeUninit<T>` will never call `T`'s drop code.
|
||||||
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
|
/// It is your responsibility to make sure `T` gets dropped if it got initialized.
|
||||||
///
|
///
|
||||||
|
Loading…
Reference in New Issue
Block a user