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:
bluss
2018-12-22 14:25:16 +01:00
parent 2316b85fbc
commit 85d9a06a62
+1
View File
@@ -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>,