src/direct_product.rs

branch
dev
changeset 120
07e487685b29
parent 119
cc0c6a8d0933
child 121
fc7d923ff6e7
--- a/src/direct_product.rs	Thu May 01 02:09:50 2025 -0500
+++ b/src/direct_product.rs	Thu May 01 02:13:44 2025 -0500
@@ -125,26 +125,26 @@
 impl_binary!(Sub, sub);
 
 macro_rules! impl_scalar {
-    ($trait:ident, $fn:ident, $F:ty) => {
-        impl<A, B> $trait<$F> for Pair<A, B>
+    ($trait:ident, $fn:ident) => {
+        impl<A, B, F: Num> $trait<F> for Pair<A, B>
         where
-            A: $trait<$F>,
-            B: $trait<$F>,
+            A: $trait<F>,
+            B: $trait<F>,
         {
             type Output = Pair<A::Output, B::Output>;
-            fn $fn(self, t: $F) -> Self::Output {
+            fn $fn(self, t: F) -> Self::Output {
                 let Pair(a, b) = self;
                 Pair(a.$fn(t), b.$fn(t))
             }
         }
 
-        impl<'a, A, B> $trait<$F> for &'a Pair<A, B>
+        impl<'a, A, B, F: Num> $trait<F> for &'a Pair<A, B>
         where
-            &'a A: $trait<$F>,
-            &'a B: $trait<$F>,
+            &'a A: $trait<F>,
+            &'a B: $trait<F>,
         {
-            type Output = Pair<<&'a A as $trait<$F>>::Output, <&'a B as $trait<$F>>::Output>;
-            fn $fn(self, t: $F) -> Self::Output {
+            type Output = Pair<<&'a A as $trait<F>>::Output, <&'a B as $trait<F>>::Output>;
+            fn $fn(self, t: F) -> Self::Output {
                 let Pair(ref a, ref b) = self;
                 Pair(a.$fn(t), b.$fn(t))
             }
@@ -177,10 +177,10 @@
     };
 }
 
-impl_scalar!(Mul, mul, f32);
-impl_scalar!(Mul, mul, f64);
-impl_scalar!(Sub, sub, f32);
-impl_scalar!(Sub, sub, f64);
+impl_scalar!(Mul, mul);
+//impl_scalar!(Mul, mul, f64);
+impl_scalar!(Sub, sub);
+//impl_scalar!(Sub, sub, f64);
 
 macro_rules! impl_scalar_lhs {
     ($trait:ident, $fn:ident, $F:ty) => {

mercurial