From 5cdd2c3ee1021a2ba5be38e130e3b78f3c3174cd Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 5 Sep 2024 16:05:47 -0700 Subject: [PATCH] must be less generic to avoid conflict with convenience operators --- fixed_wide_vectors/src/macros/vector.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/fixed_wide_vectors/src/macros/vector.rs b/fixed_wide_vectors/src/macros/vector.rs index 2596138..d8766be 100644 --- a/fixed_wide_vectors/src/macros/vector.rs +++ b/fixed_wide_vectors/src/macros/vector.rs @@ -130,24 +130,36 @@ macro_rules! impl_vector { #[macro_export(local_inner_macros)] macro_rules! impl_vector_operator { ($trait: ident, $method: ident ) => { - impl,U,V> core::ops::$trait> for Vector{ - type Output=Vector; - fn $method(self,rhs:Vector)->Self::Output{ + impl> core::ops::$trait for Vector{ + type Output=Self; + fn $method(self,rhs:Self)->Self::Output{ self.map_zip(rhs,|(a,b)|a.$method(b)) } } + impl+Copy> core::ops::$trait for Vector{ + type Output=Self; + fn $method(self,rhs:T)->Self::Output{ + self.map(|t|t.$method(rhs)) + } + } } } #[doc(hidden)] #[macro_export(local_inner_macros)] macro_rules! impl_vector_assign_operator { ($trait: ident, $method: ident ) => { - impl,U> core::ops::$trait> for Vector{ - fn $method(&mut self,rhs:Vector){ + impl core::ops::$trait for Vector{ + fn $method(&mut self,rhs:Self){ self.array.iter_mut().zip(rhs.array) .for_each(|(a,b)|a.$method(b)) } } + impl core::ops::$trait for Vector{ + fn $method(&mut self,rhs:T){ + self.array.iter_mut() + .for_each(|t|t.$method(rhs)) + } + } } }