fix abs_diff bug

This commit is contained in:
Aaron Kutch
2020-12-10 17:00:45 -06:00
parent bffd24076b
commit 0ce47b3c1f

View File

@@ -250,7 +250,11 @@ macro_rules! int_impl {
} }
fn abs_diff(self, other: Self) -> Self { fn abs_diff(self, other: Self) -> Self {
(self.wrapping_sub(other) as $ity).wrapping_abs() as $uty if self < other {
other.wrapping_sub(self)
} else {
self.wrapping_sub(other)
}
} }
int_impl_common!($uty); int_impl_common!($uty);