2 // revisions: mirunsafeck thirunsafeck
3 // [thirunsafeck]compile-flags: -Z thir-unsafeck
7 use std::mem::ManuallyDrop;
9 union MaybeItem<T: Iterator> {
10 elem: ManuallyDrop<T::Item>,
14 union U<A, B> where A: Copy, B: Copy {
19 unsafe fn union_transmute<A, B>(a: A) -> B where A: Copy, B: Copy {
25 let b = union_transmute::<(u8, u8), u16>((1, 1));
26 assert_eq!(b, (1 << 8) + 1);
28 let v: Vec<u8> = vec![1, 2, 3];
31 let mi = MaybeItem::<std::slice::Iter<_>> { elem: ManuallyDrop::new(i.next().unwrap()) };
32 assert_eq!(**mi.elem, 2);