Skip to content

Commit 85d9a06

Browse files
committed
FIX: Use repr(C) MaybeUninit after discussion with RalfJung
We have a recommendation from the unsafe-wg (no rule yet), that repr(C) for unions should work this way, so that we can cast from the union type to one of its fields.
1 parent 2316b85 commit 85d9a06

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/maybe_uninit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::mem::ManuallyDrop;
77
/// this wraps a value that can be wholly or partially uninitialized;
88
/// it also has no drop regardless of the type of T.
99
#[derive(Copy)]
10+
#[repr(C)] // for cast from self ptr to value
1011
pub union MaybeUninit<T> {
1112
empty: (),
1213
value: ManuallyDrop<T>,

0 commit comments

Comments
 (0)