Skip to content

Commit 21626ac

Browse files
authored
Clarify that round-tripping is sound so long as bytes are initialized
1 parent 0792da3 commit 21626ac

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/core/src/mem/maybe_uninit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ use crate::{fmt, intrinsics, ptr, slice};
276276
/// may not be preserved in `MaybeUninit<U>`, and so `transmute(u)` may produce a `T` with
277277
/// uninitialized bytes in these positions. This is an active area of discussion, and this code
278278
/// may become sound in the future.
279+
///
280+
/// Note that, so long as every byte position which is initialized in `T` is also initialized
281+
/// in `U`, then the preceding `identity` example *is* sound.
279282
#[stable(feature = "maybe_uninit", since = "1.36.0")]
280283
// Lang item so we can wrap other types in it. This is useful for coroutines.
281284
#[lang = "maybe_uninit"]

0 commit comments

Comments
 (0)