Closed Alextopher closed 5 months ago
This playground link shows off the expected behavior https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=32d06a7fb1e8473fea5e3c460add8944
Further changes here:
NetworkSize
explaining how comparisons work.NetworkSize::as_u128()
function to simplify conversionInto<T>
implementations preferring From<T>
which derives Into<T>
https://doc.rust-lang.org/rust-by-example/conversion/from_into.html PartialEq
, Hash
test from the playground as a test in this crate.This fixes a bug introduced in #175
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
.