Skip to content

Why do I have to implement __hash__() for a Rust enum with derived Hash trait? #3557

Discussion options

You must be logged in to vote

Oof, I'm pretty sure that this is caused because we generate a default implementation of ordering for you. As per the docs for __eq__ and friends:

Note that implementing any of these methods will cause Python not to generate a default __hash__ implementation, so consider also implementing __hash__.

So I'd consider this a bug. I'll create an issue now.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@pemistahl
Comment options

Answer selected by pemistahl
Comment options

You must be logged in to vote
2 replies
@davidhewitt
Comment options

@sheldonrong
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants