about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2016-04-17 21:57:11 -0700
committerMichael Howell <michael@notriddle.com>2016-04-20 15:23:24 -0700
commit8a8c432f7471a76bdb9179fe622968f6eb381c85 (patch)
treef7a9a7fccefbd007a5b94c8b3a13eeaf157a75e4 /src/libcore/num
parented7c56796ef17f13227a50dc1a72a018b1d5e33f (diff)
Implement negation for wrapping numerals.
Fixes #33037
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/wrapping.rs9
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
+            }
+        }
     )*)
 }