From 8a8c432f7471a76bdb9179fe622968f6eb381c85 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 17 Apr 2016 21:57:11 -0700 Subject: [PATCH] Implement negation for wrapping numerals. Fixes #33037 --- src/libcore/num/wrapping.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index e28a36af2f322..04e8bc4913bdc 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 + } + } )*) }