diff --git a/src/arith/mod.rs b/src/arith/mod.rs index a6c867636..78baea368 100644 --- a/src/arith/mod.rs +++ b/src/arith/mod.rs @@ -671,6 +671,7 @@ where macro_rules! arith_scalar_func { ($rust_type: ty, $op_name:ident, $fn_name: ident) => { + // Implement (&Array op_name rust_type) impl<'f, T> $op_name<$rust_type> for &'f Array where T: HasAfEnum + ImplicitPromote<$rust_type>, @@ -685,6 +686,7 @@ macro_rules! arith_scalar_func { } } + // Implement (Array op_name rust_type) impl $op_name<$rust_type> for Array where T: HasAfEnum + ImplicitPromote<$rust_type>, @@ -698,6 +700,34 @@ macro_rules! arith_scalar_func { $fn_name(&self, &temp, false) } } + + // Implement (rust_type op_name &Array) + impl<'f, T> $op_name<&'f Array> for $rust_type + where + T: HasAfEnum + ImplicitPromote<$rust_type>, + $rust_type: HasAfEnum + ImplicitPromote, + <$rust_type as ImplicitPromote>::Output: HasAfEnum, + { + type Output = Array<<$rust_type as ImplicitPromote>::Output>; + + fn $fn_name(self, rhs: &'f Array) -> Self::Output { + $fn_name(&self, rhs, false) + } + } + + // Implement (rust_type op_name Array) + impl $op_name> for $rust_type + where + T: HasAfEnum + ImplicitPromote<$rust_type>, + $rust_type: HasAfEnum + ImplicitPromote, + <$rust_type as ImplicitPromote>::Output: HasAfEnum, + { + type Output = Array<<$rust_type as ImplicitPromote>::Output>; + + fn $fn_name(self, rhs: Array) -> Self::Output { + $fn_name(&self, &rhs, false) + } + } }; }