Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum E {
- A,
- B,
- C,
- D(i32),
- }
- impl E {
- fn is_unit_type(&self) -> bool {
- match self {
- E::A | E::B | E::C => true,
- _ => false
- }
- }
- }
- fn main() {
- match &E::A {
- E::D(i) => println!("{}", i),
- other if other.is_unit_type() => println!("unit type"),
- // is there a way to let the compiler know there are no more possible matches?
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement