mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 22:53:28 +00:00
Apply suggestion for overflowing_add_signed
Co-authored-by: kennytm <kennytm@gmail.com>
This commit is contained in:
parent
fe11483afa
commit
ab9f8a0b59
@ -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`
|
||||
|
Loading…
Reference in New Issue
Block a user