diff --git a/src/int.rs b/src/int.rs index 0aa980c..ff9d35d 100644 --- a/src/int.rs +++ b/src/int.rs @@ -13,7 +13,7 @@ use crate::uint::U256; use core::{mem::MaybeUninit, num::ParseIntError}; /// A 256-bit signed integer type. -#[derive(Clone, Copy, Default, Eq, Hash)] +#[derive(Clone, Copy, Default, Eq)] #[repr(transparent)] pub struct I256(pub [i128; 2]); diff --git a/src/macros/cmp.rs b/src/macros/cmp.rs index f9a9c0c..48f4e94 100644 --- a/src/macros/cmp.rs +++ b/src/macros/cmp.rs @@ -4,10 +4,13 @@ macro_rules! impl_cmp { ( impl Cmp for $int:ident ($prim:ident); ) => { - impl PartialOrd for $int { + impl ::core::hash::Hash for $int { #[inline] - fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> { - Some(self.cmp(other)) + fn hash(&self, hasher: &mut H) + where + H: ::core::hash::Hasher, + { + ::core::hash::Hash::hash(&self.0, hasher); } } @@ -36,6 +39,13 @@ macro_rules! impl_cmp { } } + impl PartialOrd for $int { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> { + Some(self.cmp(other)) + } + } + impl PartialOrd<$prim> for $int { #[inline] fn partial_cmp(&self, rhs: &$prim) -> Option<::core::cmp::Ordering> { diff --git a/src/uint.rs b/src/uint.rs index 6184f61..3a1e89f 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -13,7 +13,7 @@ use crate::I256; use core::{mem::MaybeUninit, num::ParseIntError}; /// A 256-bit unsigned integer type. -#[derive(Clone, Copy, Default, Eq, Hash)] +#[derive(Clone, Copy, Default, Eq)] #[repr(transparent)] pub struct U256(pub [u128; 2]);