From 64fde2002b1cdd2a7cdd1ef724d1ccea6b33e3b3 Mon Sep 17 00:00:00 2001 From: Norbert Nemec Date: Sun, 1 Sep 2019 16:14:47 +0200 Subject: [PATCH] replace default -> default_fn!() --- src/quaternion.rs | 4 ++-- src/vector.rs | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/quaternion.rs b/src/quaternion.rs index b54149d..a681d08 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -271,9 +271,9 @@ impl InnerSpace for Quaternion { #[cfg(feature = "simd")] impl InnerSpace for Quaternion { #[inline] - default fn dot(self, other: Quaternion) -> S { + default_fn!( dot(self, other: Quaternion) -> S { self.s * other.s + self.v.dot(other.v) - } + } ); } #[cfg(feature = "simd")] diff --git a/src/vector.rs b/src/vector.rs index 5f4b4ca..8bbee4d 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -487,7 +487,7 @@ macro_rules! impl_vector_default { type Output = $VectorN; #[inline] - default fn neg(self) -> $VectorN { $VectorN::new($(-self.$field),+) } + default_fn!( neg(self) -> $VectorN { $VectorN::new($(-self.$field),+) } ); } impl approx::AbsDiffEq for $VectorN { @@ -586,30 +586,30 @@ macro_rules! impl_vector_default { }); impl ElementWise for $VectorN { - #[inline] default fn add_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field + rhs.$field),+) } - #[inline] default fn sub_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field - rhs.$field),+) } - #[inline] default fn mul_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field * rhs.$field),+) } - #[inline] default fn div_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field / rhs.$field),+) } + #[inline] default_fn!( add_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field + rhs.$field),+) } ); + #[inline] default_fn!( sub_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field - rhs.$field),+) } ); + #[inline] default_fn!( mul_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field * rhs.$field),+) } ); + #[inline] default_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),+) } - #[inline] default fn add_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field += rhs.$field);+ } - #[inline] default fn sub_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field -= rhs.$field);+ } - #[inline] default fn mul_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field *= rhs.$field);+ } - #[inline] default fn div_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field /= rhs.$field);+ } + #[inline] default_fn!( add_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field += rhs.$field);+ } ); + #[inline] default_fn!( sub_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field -= rhs.$field);+ } ); + #[inline] default_fn!( mul_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field *= rhs.$field);+ } ); + #[inline] default_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 { - #[inline] default fn add_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field + rhs),+) } - #[inline] default fn sub_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field - rhs),+) } - #[inline] default fn mul_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field * rhs),+) } - #[inline] default fn div_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field / rhs),+) } + #[inline] default_fn!( add_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field + rhs),+) } ); + #[inline] default_fn!( sub_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field - rhs),+) } ); + #[inline] default_fn!( mul_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field * rhs),+) } ); + #[inline] default_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),+) } - #[inline] default fn add_assign_element_wise(&mut self, rhs: S) { $(self.$field += rhs);+ } - #[inline] default fn sub_assign_element_wise(&mut self, rhs: S) { $(self.$field -= rhs);+ } - #[inline] default fn mul_assign_element_wise(&mut self, rhs: S) { $(self.$field *= rhs);+ } - #[inline] default fn div_assign_element_wise(&mut self, rhs: S) { $(self.$field /= rhs);+ } + #[inline] default_fn!( add_assign_element_wise(&mut self, rhs: S) { $(self.$field += rhs);+ } ); + #[inline] default_fn!( sub_assign_element_wise(&mut self, rhs: S) { $(self.$field -= rhs);+ } ); + #[inline] default_fn!( mul_assign_element_wise(&mut self, rhs: S) { $(self.$field *= rhs);+ } ); + #[inline] default_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);+ } }