From 11a864b6f70bd350f9eb61953fc06ef1e449a87b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 25 May 2015 02:23:57 +0200 Subject: [PATCH] Add test for Option> to be sure --- src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 606fec9..386c05e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -784,3 +784,14 @@ fn test_insert() { assert_eq!(v.insert(1, 1), Some(1)); assert_eq!(v.insert(2, 1), Some(1)); } + +#[test] +fn test_in_option() { + // Sanity check that we are sound w.r.t Option & non-nullable layout optimization. + let mut v = Some(ArrayVec::<[&i32; 1]>::new()); + assert!(v.is_some()); + unsafe { + *v.as_mut().unwrap().get_unchecked_mut(0) = mem::zeroed(); + } + assert!(v.is_some()); +}