Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
16 changes: 13 additions & 3 deletions src/macros/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<H>(&self, hasher: &mut H)
where
H: ::core::hash::Hasher,
{
::core::hash::Hash::hash(&self.0, hasher);
}
}

Expand Down Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down