Skip to content

Commit 197ad6a

Browse files
joshlfRalfJung
andauthored
Update library/core/src/mem/maybe_uninit.rs
Co-authored-by: Ralf Jung <[email protected]>
1 parent fc3ba91 commit 197ad6a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,12 @@ use crate::{fmt, intrinsics, ptr, slice};
279279
/// be undefined behavior or yield a value different from `t` due to those bytes being lost. This is an active area of discussion, and this code
280280
/// may become sound in the future.
281281
///
282-
/// Note that, so long as no such byte offsets exist, then the preceding `identity` example *is* sound.
282+
/// However, so long as no such byte offsets exist, then the preceding `identity` example *is* sound.
283+
/// In particular, since `[u8; N]` has no padding bytes, transmuting `t` to `MaybeUninit<[u8; size_of::<T>]>`
284+
/// and back will always produce the original value `t` again. This is true even if `t` contains [provenance]:
285+
/// the resulting value will have the same provenance as the original `t`.
286+
///
287+
/// [provenance]: crate::ptr#provenance
283288
///
284289
/// [reference-byte]: ../../reference/memory-model.html#bytes
285290
///

0 commit comments

Comments
 (0)