From e333a57a1952bca66e8063f80d3b6915b90db06b Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Wed, 8 Jul 2015 15:02:18 +0200 Subject: [PATCH 1/2] Implement Div for Wrapping Resolves #26867 --- src/libcore/num/wrapping.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 748ed29e3a3..1636a1e2703 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -119,6 +119,16 @@ macro_rules! wrapping_impl { } } + #[stable(feature = "rust1", since = "1.3.0")] + impl Div for Wrapping<$t> { + type Output = Wrapping<$t>; + + #[inline(always)] + fn div(self, other: Wrapping<$t>) -> Wrapping<$t> { + Wrapping(self.0 / other.0) + } + } + #[stable(feature = "rust1", since = "1.0.0")] impl Not for Wrapping<$t> { type Output = Wrapping<$t>; From a89b3ea3fcf1cd4b24f86d223fcc8f09c0ea75a3 Mon Sep 17 00:00:00 2001 From: Mathijs van de Nes Date: Wed, 8 Jul 2015 15:44:50 +0200 Subject: [PATCH 2/2] Use wrapping_div call and correct the feature name --- src/libcore/num/wrapping.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 1636a1e2703..2e3b34af513 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -119,13 +119,13 @@ macro_rules! wrapping_impl { } } - #[stable(feature = "rust1", since = "1.3.0")] + #[stable(feature = "wrapping_div", since = "1.3.0")] impl Div for Wrapping<$t> { type Output = Wrapping<$t>; #[inline(always)] fn div(self, other: Wrapping<$t>) -> Wrapping<$t> { - Wrapping(self.0 / other.0) + Wrapping(self.0.wrapping_div(other.0)) } }