```"),
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline]
- pub fn wrapping_neg(self) -> Self {
+ pub const fn wrapping_neg(self) -> Self {
self.overflowing_neg().0
}
}
```"),
#[inline]
#[stable(feature = "wrapping", since = "1.7.0")]
- pub fn overflowing_neg(self) -> (Self, bool) {
- if self == Self::min_value() {
- (Self::min_value(), true)
- } else {
- (-self, false)
- }
+ pub const fn overflowing_neg(self) -> (Self, bool) {
+ ((!self).wrapping_add(1), self == Self::min_value())
}
}
/// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[inline]
- pub fn wrapping_neg(self) -> Self {
+ pub const fn wrapping_neg(self) -> Self {
self.overflowing_neg().0
}
```"),
#[inline]
#[stable(feature = "wrapping", since = "1.7.0")]
- pub fn overflowing_neg(self) -> (Self, bool) {
+ pub const fn overflowing_neg(self) -> (Self, bool) {
((!self).wrapping_add(1), self != 0)
}
}