1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
// run-pass #![allow(dead_code)] enum Empty { } enum Test1 { A(u8), B(Empty), } enum Test2 { A(u8), B(Empty), C, } fn bar() -> Option<Empty> { None } fn main() { if let Some(x) = bar() { Test1::B(x); } if let Some(x) = bar() { Test2::B(x); } }