While that makes sense, I’d expect enums to implement the Eq and Hash traits by default. That’s not the case.
I assume the reason they don’t is that implementing a trait is part of the API of a type, and so you should have to explicitly say that you’re going to support it and not later modify the enum in a way that makes implementing Eq or Hash impossible.
Kinda fun how I’ve never had to do self referencing types with rust in all my time using it. Maybe I just avoid them or have a different type of problems to solve. Though it feels like I’m missing out on knowledge because I’ve never done as crazy borrowck puzzels as self referencing stuff like this.
I assume the reason they don’t is that implementing a trait is part of the API of a type, and so you should have to explicitly say that you’re going to support it and not later modify the enum in a way that makes implementing Eq or Hash impossible.
Automatically deriving Eq would already break with floats which can only implement PartialEq when strictly following the rules.
Kinda fun how I’ve never had to do self referencing types with rust in all my time using it. Maybe I just avoid them or have a different type of problems to solve. Though it feels like I’m missing out on knowledge because I’ve never done as crazy
borrowck
puzzels as self referencing stuff like this.