about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-09-11 08:08:39 +0200
committerRalf Jung <post@ralfj.de>2024-09-11 08:08:39 +0200
commitd4ac759542ec9789ad5ba9a12abe112e7158ecab (patch)
tree044367a7260b37831c20f26d0ae9b91041e5a44c
parenta9fb00bfa4b3038c855b2097b54e05e8c198c183 (diff)
downloadrust-d4ac759542ec9789ad5ba9a12abe112e7158ecab.tar.gz
rust-d4ac759542ec9789ad5ba9a12abe112e7158ecab.zip
MaybeUninit::zeroed: mention that padding is not zeroed
-rw-r--r--library/core/src/mem/maybe_uninit.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs
index 4be2e5ef1ea..0154caa7c24 100644
--- a/library/core/src/mem/maybe_uninit.rs
+++ b/library/core/src/mem/maybe_uninit.rs
@@ -351,6 +351,9 @@ impl<T> MaybeUninit<T> {
     /// but `MaybeUninit<&'static i32>::zeroed()` is not because references must not
     /// 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.
     /// It is your responsibility to make sure `T` gets dropped if it got initialized.
     ///