diff --git a/src/bigint.rs b/src/bigint.rs index fb5feff..a7af4c9 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -489,34 +489,32 @@ macro_rules! impl_from_larger { } macro_rules! impl_ord_literal { - ($(($($prim: ty),+), $base: ty), *) => { + ($($prim: ty),+) => { $( - $( - impl PartialEq<$prim> for BigInt { - fn eq(&self, other: &$prim) -> bool { - self == &BigInt::from(*other) - } + impl PartialEq<$prim> for BigInt { + fn eq(&self, other: &$prim) -> bool { + self == &BigInt::from(*other) } + } - impl PartialEq for $prim { - fn eq(&self, other: &BigInt) -> bool { - &BigInt::from(*self) == other - } + impl PartialEq for $prim { + fn eq(&self, other: &BigInt) -> bool { + &BigInt::from(*self) == other } + } - impl PartialOrd<$prim> for BigInt { - fn partial_cmp(&self, other: &$prim) -> Option { - self.partial_cmp(&BigInt::from(*other)) - } + impl PartialOrd<$prim> for BigInt { + fn partial_cmp(&self, other: &$prim) -> Option { + self.partial_cmp(&BigInt::from(*other)) } + } - impl PartialOrd for $prim { - fn partial_cmp(&self, other: &BigInt) -> Option { - (&BigInt::from(*self)).partial_cmp(other) - } + impl PartialOrd for $prim { + fn partial_cmp(&self, other: &BigInt) -> Option { + (&BigInt::from(*self)).partial_cmp(other) } - )+ - )* + } + )+ }; } @@ -524,19 +522,14 @@ macro_rules! impl_ord_literal { impl_from_larger!((i64, u64), (i128, u128)); #[cfg(target_pointer_width = "32")] impl_from_smaller!((i8, u8), (i16, u16), (i32, u32)); -#[cfg(target_pointer_width = "32")] -impl_ord_literal!((i8,u8,i16,u16,i32,u32,i64,u64), u32); -#[cfg(target_pointer_width = "32")] -static BITS: usize = 32; #[cfg(target_pointer_width = "64")] impl_from_larger!((i128, u128)); #[cfg(target_pointer_width = "64")] impl_from_smaller!((i8, u8), (i16, u16), (i32, u32), (i64, u64)); -#[cfg(target_pointer_width = "64")] -impl_ord_literal!((i8,u8,i16,u16,i32,u32,i64,u64), u32); -#[cfg(target_pointer_width = "64")] -static BITS: usize = 64; + +// Implement PartialEq and PartialOrd to compare against BigInt values +impl_ord_literal!(i8,u8,i16,u16,i32,u32,i64,u64,i128,u128); #[cfg(test)] #[cfg_attr(tarpaulin, skip)]