From 33fb2fd24f8135247295cbc9baccb3efb8bfd27f Mon Sep 17 00:00:00 2001 From: Mauro Gentile Date: Sat, 16 Apr 2022 10:52:39 +0200 Subject: [PATCH] Fixing clippy warnings --- src/macros.rs | 16 ++++------------ src/quaternion.rs | 1 - src/vector.rs | 33 ++++++++++++++++----------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 21149e1c..65952f50 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -24,7 +24,10 @@ macro_rules! default_fn { #[cfg(not(feature = "simd"))] macro_rules! default_fn { - { $($tt:tt)* } => { fn $( $tt )* }; + { $($tt:tt)* } => { + #[inline] + fn $( $tt )* + }; } /// Generates a binary operator implementation for the permutations of by-ref and by-val @@ -35,7 +38,6 @@ macro_rules! impl_operator { }) => { impl<$S: $Constraint> $Op for $Lhs { type Output = $Output; - #[inline] default_fn!($op(self) -> $Output { let $x = self; $body }); @@ -43,7 +45,6 @@ macro_rules! impl_operator { impl<'a, $S: $Constraint> $Op for &'a $Lhs { type Output = $Output; - #[inline] default_fn!($op(self) -> $Output { let $x = self; $body }); @@ -55,7 +56,6 @@ macro_rules! impl_operator { }) => { impl<$S: $Constraint> $Op<$Rhs> for $Lhs { type Output = $Output; - #[inline] default_fn!($op(self, other: $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -63,7 +63,6 @@ macro_rules! impl_operator { impl<'a, $S: $Constraint> $Op<$Rhs> for &'a $Lhs { type Output = $Output; - #[inline] default_fn!($op(self, other: $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -75,7 +74,6 @@ macro_rules! impl_operator { }) => { impl<$S: $Constraint> $Op<$Rhs> for $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -83,7 +81,6 @@ macro_rules! impl_operator { impl<'a, $S: $Constraint> $Op<&'a $Rhs> for $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: &'a $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -91,7 +88,6 @@ macro_rules! impl_operator { impl<'a, $S: $Constraint> $Op<$Rhs> for &'a $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -99,7 +95,6 @@ macro_rules! impl_operator { impl<'a, 'b, $S: $Constraint> $Op<&'a $Rhs> for &'b $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: &'a $Rhs) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -111,7 +106,6 @@ macro_rules! impl_operator { }) => { impl $Op<$Rhs<$S>> for $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: $Rhs<$S>) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -119,7 +113,6 @@ macro_rules! impl_operator { impl<'a> $Op<&'a $Rhs<$S>> for $Lhs { type Output = $Output; - #[inline] default_fn!( $op(self, other: &'a $Rhs<$S>) -> $Output { let ($lhs, $rhs) = (self, other); $body }); @@ -132,7 +125,6 @@ macro_rules! impl_assignment_operator { fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block }) => { impl<$S: $Constraint + $Op<$S>> $Op<$Rhs> for $Lhs { - #[inline] default_fn!( $op(&mut $lhs, $rhs: $Rhs) $body ); } }; diff --git a/src/quaternion.rs b/src/quaternion.rs index 7b333854..f0360799 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -238,7 +238,6 @@ impl Quaternion { } impl InnerSpace for Quaternion { - #[inline] default_fn!( dot(self, other: Quaternion) -> S { self.s * other.s + self.v.dot(other.v) } ); diff --git a/src/vector.rs b/src/vector.rs index a5696870..e86e6d7b 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -209,7 +209,6 @@ macro_rules! impl_vector { impl> Neg for $VectorN { type Output = $VectorN; - #[inline] default_fn!( neg(self) -> $VectorN { $VectorN::new($(-self.$field),+) } ); } @@ -309,30 +308,30 @@ macro_rules! impl_vector { }); 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),+) } ); + default_fn!( add_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field + rhs.$field),+) } ); + default_fn!( sub_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field - rhs.$field),+) } ); + default_fn!( mul_element_wise(self, rhs: $VectorN) -> $VectorN { $VectorN::new($(self.$field * rhs.$field),+) } ); + 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);+ } ); + default_fn!( add_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field += rhs.$field);+ } ); + default_fn!( sub_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field -= rhs.$field);+ } ); + default_fn!( mul_assign_element_wise(&mut self, rhs: $VectorN) { $(self.$field *= rhs.$field);+ } ); + 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),+) } ); + default_fn!( add_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field + rhs),+) } ); + default_fn!( sub_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field - rhs),+) } ); + default_fn!( mul_element_wise(self, rhs: S) -> $VectorN { $VectorN::new($(self.$field * rhs),+) } ); + 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);+ } ); + default_fn!( add_assign_element_wise(&mut self, rhs: S) { $(self.$field += rhs);+ } ); + default_fn!( sub_assign_element_wise(&mut self, rhs: S) { $(self.$field -= rhs);+ } ); + default_fn!( mul_assign_element_wise(&mut self, rhs: S) { $(self.$field *= rhs);+ } ); + 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);+ } }