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.
This commit is contained in:
@@ -7,6 +7,7 @@ use std::mem::ManuallyDrop;
|
|||||||
/// this wraps a value that can be wholly or partially uninitialized;
|
/// this wraps a value that can be wholly or partially uninitialized;
|
||||||
/// it also has no drop regardless of the type of T.
|
/// it also has no drop regardless of the type of T.
|
||||||
#[derive(Copy)]
|
#[derive(Copy)]
|
||||||
|
#[repr(C)] // for cast from self ptr to value
|
||||||
pub union MaybeUninit<T> {
|
pub union MaybeUninit<T> {
|
||||||
empty: (),
|
empty: (),
|
||||||
value: ManuallyDrop<T>,
|
value: ManuallyDrop<T>,
|
||||||
|
|||||||
Reference in New Issue
Block a user