From 07301eb4d0d8cc7994aa01d72a96b9e247315241 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Fri, 15 Apr 2016 17:16:50 +1000 Subject: [PATCH] Stabilise assignment operators Assignment operators were stabilised in Rust 1.8. --- src/array.rs | 10 +++++----- src/macros.rs | 1 - src/matrix.rs | 2 -- src/num.rs | 11 ----------- src/vector.rs | 20 ++++++++++---------- 5 files changed, 15 insertions(+), 29 deletions(-) diff --git a/src/array.rs b/src/array.rs index df068de..3f1f14c 100644 --- a/src/array.rs +++ b/src/array.rs @@ -78,9 +78,9 @@ pub trait ElementWise { fn div_element_wise(self, rhs: Rhs) -> Self; fn rem_element_wise(self, rhs: Rhs) -> Self; - #[cfg(feature = "unstable")] fn add_assign_element_wise(&mut self, rhs: Rhs); - #[cfg(feature = "unstable")] fn sub_assign_element_wise(&mut self, rhs: Rhs); - #[cfg(feature = "unstable")] fn mul_assign_element_wise(&mut self, rhs: Rhs); - #[cfg(feature = "unstable")] fn div_assign_element_wise(&mut self, rhs: Rhs); - #[cfg(feature = "unstable")] fn rem_assign_element_wise(&mut self, rhs: Rhs); + fn add_assign_element_wise(&mut self, rhs: Rhs); + fn sub_assign_element_wise(&mut self, rhs: Rhs); + fn mul_assign_element_wise(&mut self, rhs: Rhs); + fn div_assign_element_wise(&mut self, rhs: Rhs); + fn rem_assign_element_wise(&mut self, rhs: Rhs); } diff --git a/src/macros.rs b/src/macros.rs index c4d60a2..f1fb8b6 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -121,7 +121,6 @@ macro_rules! impl_assignment_operator { (<$S:ident: $Constraint:ident> $Op:ident<$Rhs:ty> for $Lhs:ty { fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block }) => { - #[cfg(feature = "unstable")] impl<$S: $Constraint + $Op<$S>> $Op<$Rhs> for $Lhs { #[inline] fn $op(&mut $lhs, $rhs: $Rhs) $body diff --git a/src/matrix.rs b/src/matrix.rs index b6a3bb9..dfc28c3 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -865,11 +865,9 @@ macro_rules! impl_operators { impl_operator!( Sub<$MatrixN > for $MatrixN { fn sub(lhs, rhs) -> $MatrixN { $MatrixN { $($field: lhs.$field - rhs.$field),+ } } }); - #[cfg(feature = "unstable")] impl> AddAssign<$MatrixN> for $MatrixN { fn add_assign(&mut self, other: $MatrixN) { $(self.$field += other.$field);+ } } - #[cfg(feature = "unstable")] impl> SubAssign<$MatrixN> for $MatrixN { fn sub_assign(&mut self, other: $MatrixN) { $(self.$field -= other.$field);+ } } diff --git a/src/num.rs b/src/num.rs index c29a07e..622c2a9 100644 --- a/src/num.rs +++ b/src/num.rs @@ -17,7 +17,6 @@ use approx::ApproxEq; use std::cmp; use std::fmt; -#[cfg(feature = "unstable")] use std::ops::*; use rust_num::{Float, Num, NumCast}; @@ -62,16 +61,6 @@ partial_ord_float!(f64); /// Base numeric types with partial ordering -#[cfg(not(feature = "unstable"))] -pub trait BaseNum where - Self: Copy + Clone + fmt::Debug, - Self: Num + NumCast, - Self: PartialOrd + cmp::PartialOrd, -{} - - -/// Base numeric types with partial ordering -#[cfg(feature = "unstable")] pub trait BaseNum where Self: Copy + Clone + fmt::Debug, Self: Num + NumCast, diff --git a/src/vector.rs b/src/vector.rs index 6fb813c..112ce14 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -267,11 +267,11 @@ macro_rules! impl_vector { #[inline] fn div_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field / rhs.$field),+) } #[inline] fn rem_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field % rhs.$field),+) } - #[cfg(feature = "unstable")] #[inline] fn add_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field += rhs.$field);+ } - #[cfg(feature = "unstable")] #[inline] fn sub_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field -= rhs.$field);+ } - #[cfg(feature = "unstable")] #[inline] fn mul_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field *= rhs.$field);+ } - #[cfg(feature = "unstable")] #[inline] fn div_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field /= rhs.$field);+ } - #[cfg(feature = "unstable")] #[inline] fn rem_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field %= rhs.$field);+ } + #[inline] fn add_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field += rhs.$field);+ } + #[inline] fn sub_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field -= rhs.$field);+ } + #[inline] fn mul_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field *= rhs.$field);+ } + #[inline] fn div_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field /= rhs.$field);+ } + #[inline] fn rem_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field %= rhs.$field);+ } } impl ElementWise for $VectorN { @@ -281,11 +281,11 @@ macro_rules! impl_vector { #[inline] fn div_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field / rhs),+) } #[inline] fn rem_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field % rhs),+) } - #[cfg(feature = "unstable")] #[inline] fn add_assign_element_wise(&mut self, rhs: S) { $(self.$field += rhs);+ } - #[cfg(feature = "unstable")] #[inline] fn sub_assign_element_wise(&mut self, rhs: S) { $(self.$field -= rhs);+ } - #[cfg(feature = "unstable")] #[inline] fn mul_assign_element_wise(&mut self, rhs: S) { $(self.$field *= rhs);+ } - #[cfg(feature = "unstable")] #[inline] fn div_assign_element_wise(&mut self, rhs: S) { $(self.$field /= rhs);+ } - #[cfg(feature = "unstable")] #[inline] fn rem_assign_element_wise(&mut self, rhs: S) { $(self.$field %= rhs);+ } + #[inline] fn add_assign_element_wise(&mut self, rhs: S) { $(self.$field += rhs);+ } + #[inline] fn sub_assign_element_wise(&mut self, rhs: S) { $(self.$field -= rhs);+ } + #[inline] fn mul_assign_element_wise(&mut self, rhs: S) { $(self.$field *= rhs);+ } + #[inline] fn div_assign_element_wise(&mut self, rhs: S) { $(self.$field /= rhs);+ } + #[inline] fn rem_assign_element_wise(&mut self, rhs: S) { $(self.$field %= rhs);+ } } impl_scalar_ops!($VectorN { $($field),+ });