I'd like to implement `PartialOrd`

for an enum where the inner value shall not be taken into account:

```
#[derive(PartialOrd, Ord, PartialEq, Eq)]
enum E {
First(u32),
// potentially some more variants
Last(u32),
}
```

This doesn't work because the inner `u32`

will be recursively evaluated due to the `derive`

. `std::mem::discriminant`

doesn't help because it's not `[Partial]Ord`

.

I peeked into the macro expansion to see how the `derive`

was implemented. I found `core::intrinsics::discriminant_value`

which is unavailable to *normal* code.

I know two workarounds:

- implement a private
`my_discriminant(&self) -> u8`

and hard-code the discriminants - implement
`[partial_]ord()`

with an exhaustive`match (self, other) { ā¦ }`

I had a similar problem before, trying to find the minimum of two `Option`

s (where `None`

should come first). As there were only two variants it was trivial to work around.

Is there a nicer solution?