Add test for Option<ArrayVec<_>> to be sure

This commit is contained in:
root
2015-05-25 02:23:57 +02:00
parent 8a154e9847
commit 11a864b6f7
+11
View File
@@ -784,3 +784,14 @@ fn test_insert() {
assert_eq!(v.insert(1, 1), Some(1)); assert_eq!(v.insert(1, 1), Some(1));
assert_eq!(v.insert(2, 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());
}