From 85d9a06a62d73776b2fe7786e2d50e2833384331 Mon Sep 17 00:00:00 2001 From: bluss Date: Sat, 22 Dec 2018 14:25:16 +0100 Subject: [PATCH] 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. --- src/maybe_uninit.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/maybe_uninit.rs b/src/maybe_uninit.rs index 71ec8f0..39c6366 100644 --- a/src/maybe_uninit.rs +++ b/src/maybe_uninit.rs @@ -7,6 +7,7 @@ use std::mem::ManuallyDrop; /// this wraps a value that can be wholly or partially uninitialized; /// it also has no drop regardless of the type of T. #[derive(Copy)] +#[repr(C)] // for cast from self ptr to value pub union MaybeUninit { empty: (), value: ManuallyDrop,