@@ -403,33 +403,51 @@ arith_scalar_spec!(i32);
403403arith_scalar_spec ! ( u8 ) ;
404404
405405macro_rules! arith_func {
406- ( $op_name: ident, $fn_name: ident, $ffi_fn : ident ) => (
406+ ( $op_name: ident, $fn_name: ident) => (
407407 impl $op_name<Array > for Array {
408408 type Output = Array ;
409409
410410 fn $fn_name( self , rhs: Array ) -> Array {
411- unsafe {
412- let mut temp: i64 = 0 ;
413- let err_val = $ffi_fn( & mut temp as MutAfArray ,
414- self . get( ) as AfArray , rhs. get( ) as AfArray , 0 ) ;
415- HANDLE_ERROR ( AfError :: from( err_val) ) ;
416- Array :: from( temp)
417- }
411+ add( & self , & rhs, false )
412+ }
413+ }
414+
415+ impl <' a> $op_name<& ' a Array > for Array {
416+ type Output = Array ;
417+
418+ fn $fn_name( self , rhs: & ' a Array ) -> Array {
419+ add( & self , rhs, false )
420+ }
421+ }
422+
423+ impl <' a> $op_name<Array > for & ' a Array {
424+ type Output = Array ;
425+
426+ fn $fn_name( self , rhs: Array ) -> Array {
427+ add( self , & rhs, false )
428+ }
429+ }
430+
431+ impl <' a, ' b> $op_name<& ' a Array > for & ' b Array {
432+ type Output = Array ;
433+
434+ fn $fn_name( self , rhs: & ' a Array ) -> Array {
435+ add( self , rhs, false )
418436 }
419437 }
420438 )
421439}
422440
423- arith_func ! ( Add , add, af_add ) ;
424- arith_func ! ( Sub , sub, af_sub ) ;
425- arith_func ! ( Mul , mul, af_mul ) ;
426- arith_func ! ( Div , div, af_div ) ;
427- arith_func ! ( Rem , rem, af_rem ) ;
428- arith_func ! ( BitAnd , bitand, af_bitand ) ;
429- arith_func ! ( BitOr , bitor, af_bitor ) ;
430- arith_func ! ( BitXor , bitxor, af_bitxor ) ;
431- arith_func ! ( Shl , shl, af_bitshiftl ) ;
432- arith_func ! ( Shr , shr, af_bitshiftr ) ;
441+ arith_func ! ( Add , add ) ;
442+ arith_func ! ( Sub , sub ) ;
443+ arith_func ! ( Mul , mul ) ;
444+ arith_func ! ( Div , div ) ;
445+ arith_func ! ( Rem , rem ) ;
446+ arith_func ! ( BitAnd , bitand) ;
447+ arith_func ! ( BitOr , bitor ) ;
448+ arith_func ! ( BitXor , bitxor) ;
449+ arith_func ! ( Shl , shl ) ;
450+ arith_func ! ( Shr , shr ) ;
433451
434452#[ cfg( op_assign) ]
435453mod op_assign {
0 commit comments