From 454b86974594cd61d749089c6a079ca34b1905e5 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 4 May 2024 15:41:11 -0700 Subject: [PATCH] Use inherent `unsigned_abs` --- src/bigint.rs | 9 --------- src/bigint/division.rs | 12 ++++++------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/bigint.rs b/src/bigint.rs index d6f9f046..704bb95b 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -293,10 +293,6 @@ impl Signed for BigInt { trait UnsignedAbs { type Unsigned; - /// A convenience method for getting the absolute value of a signed primitive as unsigned - /// See also `unsigned_abs`: - fn uabs(self) -> Self::Unsigned; - fn checked_uabs(self) -> CheckedUnsignedAbs; } @@ -311,11 +307,6 @@ macro_rules! impl_unsigned_abs { impl UnsignedAbs for $Signed { type Unsigned = $Unsigned; - #[inline] - fn uabs(self) -> $Unsigned { - self.wrapping_abs() as $Unsigned - } - #[inline] fn checked_uabs(self) -> CheckedUnsignedAbs { if self >= 0 { diff --git a/src/bigint/division.rs b/src/bigint/division.rs index b230cd08..0d4d23f3 100644 --- a/src/bigint/division.rs +++ b/src/bigint/division.rs @@ -358,14 +358,14 @@ impl Rem for BigInt { #[inline] fn rem(self, other: i32) -> BigInt { - self % other.uabs() + self % other.unsigned_abs() } } impl RemAssign for BigInt { #[inline] fn rem_assign(&mut self, other: i32) { - *self %= other.uabs(); + *self %= other.unsigned_abs(); } } @@ -386,14 +386,14 @@ impl Rem for BigInt { #[inline] fn rem(self, other: i64) -> BigInt { - self % other.uabs() + self % other.unsigned_abs() } } impl RemAssign for BigInt { #[inline] fn rem_assign(&mut self, other: i64) { - *self %= other.uabs(); + *self %= other.unsigned_abs(); } } @@ -414,14 +414,14 @@ impl Rem for BigInt { #[inline] fn rem(self, other: i128) -> BigInt { - self % other.uabs() + self % other.unsigned_abs() } } impl RemAssign for BigInt { #[inline] fn rem_assign(&mut self, other: i128) { - *self %= other.uabs(); + *self %= other.unsigned_abs(); } }