netsize: Hash implementation to match PartialEq #186
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hash
andPartialEq
implementations onNetworkSize
are mutually incompatible and don't follow thestd::hash::Hash
constraints. This will cause issues if you useNetworkSize
in aHashMap
orHashSet
.Here is a playground link demonstrating the issue. https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d030b1654e0abd2515c16ffe83fcd9a0
This PR fixes this issue by writing a custom implementation of
Hash
which only use the u128 logical value of the network size, same asPartialEq
.