Given an enum where some variant(s) have named fields (struct variants, anonymous structs),
enum S {
Unnamed(i32),
Named { a: i32 },
}
how can we match pairs of them to write a reasonable equality function (without nested matches, and when we can't rely on a #[derive(PartialEq, Eq)]
)?
It's easy enough for unnamed variants as here on playground, but I nor rustc see how a match like this:
match (self, other) {
(S::Named { a }, S::Named { a }) => true,
would be right, nor how to apply @
Bindings.