From 31f95d1818ba351590099ec81314100ad49bf134 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 May 2015 17:17:17 +0200 Subject: [PATCH] Use #[repr(u8)] on the Flag enum --- src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6e82bfa..15cd179 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,10 +13,10 @@ use std::hash::{Hash, Hasher}; use std::fmt; /// Make sure the non-nullable pointer optimization does not occur! +#[repr(u8)] enum Flag { - Alive(T), Dropped, - _Unused, + Alive(T), } /// Trait for fixed size arrays. @@ -542,7 +542,8 @@ fn test_is_send_sync() { fn test_no_nonnullable_opt() { // Make sure `Flag` does not apply the non-nullable pointer optimization // as Option would do. - assert!(mem::size_of::>() > mem::size_of::<&()>()); + assert!(mem::size_of::>() > mem::size_of::<&i32>()); + assert!(mem::size_of::>>() > mem::size_of::>()); } #[test]