diff options
| author | Michael Howell <michael@notriddle.com> | 2016-04-17 21:57:11 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2016-04-20 15:23:24 -0700 |
| commit | 8a8c432f7471a76bdb9179fe622968f6eb381c85 (patch) | |
| tree | f7a9a7fccefbd007a5b94c8b3a13eeaf157a75e4 /src/libcore/num | |
| parent | ed7c56796ef17f13227a50dc1a72a018b1d5e33f (diff) | |
Implement negation for wrapping numerals.
Fixes #33037
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/wrapping.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index e28a36af2f3..04e8bc4913b 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -275,6 +275,15 @@ macro_rules! wrapping_impl { *self = *self & other; } } + + #[stable(feature = "wrapping_neg", since = "1.10.0")] + impl Neg for Wrapping<$t> { + type Output = Self; + #[inline(always)] + fn neg(self) -> Self { + Wrapping(0) - self + } + } )*) } |
