How to match enum without struct variables?

Hi All,

I have an enum like below,

enum MyEnum {
    A,
    B {c: f32, d: f32}
}

I am able to match it like below,

match myenum {
    MyEnum::A => (),
    MyEnum::B {c, d} => ()
}

I wanted to do something like below,

match myenum {
    MyEnum::A => (),
    MyEnum::B => ()
}

Is it possible?

You can do MyEnum::B { .. } to ignore the contents of the variant.

6 Likes

Thanks a lot. :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.