Skip to content

Commit ab9f8a0

Browse files
a1phyrkennytm
andcommitted
Apply suggestion for overflowing_add_signed
Co-authored-by: kennytm <[email protected]>
1 parent fe11483 commit ab9f8a0

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

library/core/src/num/uint_macros.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1528,11 +1528,8 @@ macro_rules! uint_impl {
15281528
without modifying the original"]
15291529
#[inline]
15301530
pub const fn overflowing_add_signed(self, rhs: $SignedT) -> (Self, bool) {
1531-
if rhs >= 0 {
1532-
self.overflowing_add(rhs as Self)
1533-
} else {
1534-
self.overflowing_sub(rhs.unsigned_abs())
1535-
}
1531+
let (res, overflowed) = self.overflowing_add(rhs as Self);
1532+
(res, overflowed ^ (rhs < 0))
15361533
}
15371534

15381535
/// Calculates `self` - `rhs`

0 commit comments

Comments
 (0)