mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 01:25:54 +00:00
Preserve originally intended test semantics
This commit is contained in:
parent
50ec10e605
commit
9c1ad0ff2f
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
#![feature(untagged_unions)]
|
#![feature(untagged_unions)]
|
||||||
|
|
||||||
union MaybeItem<T: Iterator> where T::Item: Copy {
|
use std::mem::ManuallyDrop;
|
||||||
elem: T::Item,
|
|
||||||
|
union MaybeItem<T: Iterator> {
|
||||||
|
elem: ManuallyDrop<T::Item>,
|
||||||
none: (),
|
none: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +27,7 @@ fn main() {
|
|||||||
let v: Vec<u8> = vec![1, 2, 3];
|
let v: Vec<u8> = vec![1, 2, 3];
|
||||||
let mut i = v.iter();
|
let mut i = v.iter();
|
||||||
i.next();
|
i.next();
|
||||||
let mi = MaybeItem::<std::slice::Iter<_>> { elem: i.next().unwrap() };
|
let mi = MaybeItem::<std::slice::Iter<_>> { elem: ManuallyDrop::new(i.next().unwrap()) };
|
||||||
assert_eq!(*mi.elem, 2);
|
assert_eq!(**mi.elem, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user