Simplify the overflowing_neg expression

This commit is contained in:
Lokathor
2019-02-01 18:43:32 -07:00
parent 26a354065c
commit 481b354c97

View File

@@ -1530,7 +1530,7 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
#[inline] #[inline]
#[stable(feature = "wrapping", since = "1.7.0")] #[stable(feature = "wrapping", since = "1.7.0")]
pub const fn overflowing_neg(self) -> (Self, bool) { pub const fn overflowing_neg(self) -> (Self, bool) {
((self ^ -1).wrapping_add(1), self == Self::min_value()) ((!self).wrapping_add(1), self == Self::min_value())
} }
} }