// run-pass #![allow(dead_code)] use std::mem::ManuallyDrop; union MaybeItem { elem: ManuallyDrop, none: (), } union U where A: Copy, B: Copy { a: A, b: B, } unsafe fn union_transmute(a: A) -> B where A: Copy, B: Copy { U { a }.b } fn main() { unsafe { let b = union_transmute::<(u8, u8), u16>((1, 1)); assert_eq!(b, (1 << 8) + 1); let v: Vec = vec![1, 2, 3]; let mut i = v.iter(); i.next(); let mi = MaybeItem::> { elem: ManuallyDrop::new(i.next().unwrap()) }; assert_eq!(**mi.elem, 2); } }