14 let mut u = U { f1: 1 };
19 assert_eq!(unsafe { u.f1 }, 5);
23 #[derive(Copy, Clone)]
34 let mut u = U { s: S { x: 1, y: 2 } };
41 assert_eq!(unsafe { u.s.x }, 5);
42 assert_eq!(unsafe { u.s.y }, 10);
64 fn is_zero(v: Value) -> bool {
67 Value { tag: Tag::I, u: U { i: 0 } } => true,
68 Value { tag: Tag::F, u: U { f } } => f == 0.0,
73 assert!(is_zero(Value { tag: Tag::I, u: U { i: 0 } }));
74 assert!(is_zero(Value { tag: Tag::F, u: U { f: 0.0 } }));
75 assert!(!is_zero(Value { tag: Tag::I, u: U { i: 1 } }));
76 assert!(!is_zero(Value { tag: Tag::F, u: U { f: 42.0 } }));
84 let u = MyUnion { f1: 10 };
87 MyUnion { f1: 10 } => {}
88 MyUnion { f2: _f2 } => panic!("foo"),