Apply suggestion for overflowing_add_signed

Co-authored-by: kennytm <kennytm@gmail.com>
This commit is contained in:
Alphyr 2021-07-30 12:11:18 +02:00 committed by Benoît du Garreau
parent fe11483afa
commit ab9f8a0b59

View File

@ -1528,11 +1528,8 @@ macro_rules! uint_impl {
without modifying the original"]
#[inline]
pub const fn overflowing_add_signed(self, rhs: $SignedT) -> (Self, bool) {
if rhs >= 0 {
self.overflowing_add(rhs as Self)
} else {
self.overflowing_sub(rhs.unsigned_abs())
}
let (res, overflowed) = self.overflowing_add(rhs as Self);
(res, overflowed ^ (rhs < 0))
}
/// Calculates `self` - `rhs`