side-step potentially panic'ing negate in fn abs
.
This commit is contained in:
parent
c34fa8b2c5
commit
e9f892acc4
@ -1321,7 +1321,11 @@ pub fn pow(self, mut exp: u32) -> $T {
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn abs(self) -> $T {
|
||||
if self.is_negative() { -self } else { self }
|
||||
if self.is_negative() {
|
||||
self.wrapping_neg()
|
||||
} else {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a number representing sign of `self`.
|
||||
|
Loading…
Reference in New Issue
Block a user