@@ -1458,13 +1458,15 @@ impl<A: Float + PartialOrd, D: Dimension> Array<A, D>
14581458// Array OPERATORS
14591459
14601460macro_rules! impl_binary_op(
1461- ( $trt: ident, $mth: ident, $imethod: ident, $imth_scalar: ident) => (
1461+ ( $trt: ident, $mth: ident, $imethod: ident, $imth_scalar: ident, $doc : expr ) => (
14621462impl <A , S , D > ArrayBase <S , D > where
14631463 A : Clone + $trt<A , Output =A >,
14641464 S : DataMut <Elem =A >,
14651465 D : Dimension ,
14661466{
1467- /// Perform an elementwise arithmetic operation between **self** and **other**,
1467+ /// Perform elementwise
1468+ #[ doc=$doc]
1469+ /// between **self** and **other**,
14681470 /// *in place*.
14691471 ///
14701472 /// If their shapes disagree, **other** is broadcast to the shape of **self**.
@@ -1486,7 +1488,9 @@ impl<A, S, D> ArrayBase<S, D> where
14861488 }
14871489 }
14881490
1489- /// Perform an elementwise arithmetic operation between **self** and the scalar **x**,
1491+ /// Perform elementwise
1492+ #[ doc=$doc]
1493+ /// between **self** and the scalar **x**,
14901494 /// *in place*.
14911495 pub fn $imth_scalar ( & mut self , x: & A )
14921496 {
@@ -1496,7 +1500,9 @@ impl<A, S, D> ArrayBase<S, D> where
14961500 }
14971501}
14981502
1499- /// Perform an elementwise arithmetic operation between **self** and **other**,
1503+ /// Perform elementwise
1504+ #[ doc=$doc]
1505+ /// between **self** and **other**,
15001506/// and return the result.
15011507///
15021508/// If their shapes disagree, **other** is broadcast to the shape of **self**.
@@ -1527,7 +1533,9 @@ impl<A, S, S2, D, E> $trt<ArrayBase<S2, E>> for ArrayBase<S, D>
15271533 }
15281534}
15291535
1530- /// Perform an elementwise arithmetic operation between **self** and **other**,
1536+ /// Perform elementwise
1537+ #[ doc=$doc]
1538+ /// between **self** and **other**,
15311539/// and return the result.
15321540///
15331541/// If their shapes disagree, **other** is broadcast to the shape of **self**.
@@ -1563,16 +1571,16 @@ impl<'a, A, S, S2, D, E> $trt<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D>
15631571 ) ;
15641572) ;
15651573
1566- impl_binary_op ! ( Add , add, iadd, iadd_scalar) ;
1567- impl_binary_op ! ( Sub , sub, isub, isub_scalar) ;
1568- impl_binary_op ! ( Mul , mul, imul, imul_scalar) ;
1569- impl_binary_op ! ( Div , div, idiv, idiv_scalar) ;
1570- impl_binary_op ! ( Rem , rem, irem, irem_scalar) ;
1571- impl_binary_op ! ( BitAnd , bitand, ibitand, ibitand_scalar) ;
1572- impl_binary_op ! ( BitOr , bitor, ibitor, ibitor_scalar) ;
1573- impl_binary_op ! ( BitXor , bitxor, ibitxor, ibitxor_scalar) ;
1574- impl_binary_op ! ( Shl , shl, ishl, ishl_scalar) ;
1575- impl_binary_op ! ( Shr , shr, ishr, ishr_scalar) ;
1574+ impl_binary_op ! ( Add , add, iadd, iadd_scalar, "Addition" ) ;
1575+ impl_binary_op ! ( Sub , sub, isub, isub_scalar, "Subtraction" ) ;
1576+ impl_binary_op ! ( Mul , mul, imul, imul_scalar, "Multiplication" ) ;
1577+ impl_binary_op ! ( Div , div, idiv, idiv_scalar, "Divsion" ) ;
1578+ impl_binary_op ! ( Rem , rem, irem, irem_scalar, "Remainder" ) ;
1579+ impl_binary_op ! ( BitAnd , bitand, ibitand, ibitand_scalar, "Bit and" ) ;
1580+ impl_binary_op ! ( BitOr , bitor, ibitor, ibitor_scalar, "Bit or" ) ;
1581+ impl_binary_op ! ( BitXor , bitxor, ibitxor, ibitxor_scalar, "Bit xor" ) ;
1582+ impl_binary_op ! ( Shl , shl, ishl, ishl_scalar, "Shift left" ) ;
1583+ impl_binary_op ! ( Shr , shr, ishr, ishr_scalar, "Shift right" ) ;
15761584
15771585#[ cfg( feature = "assign_ops" ) ]
15781586mod assign_ops {
@@ -1591,10 +1599,9 @@ mod assign_ops {
15911599
15921600
15931601 macro_rules! impl_assign_op {
1594- ( $trt: ident, $method: ident) => {
1602+ ( $trt: ident, $method: ident, $doc : expr ) => {
15951603
1596- /// Perform an elementwise in place arithmetic operation between **self** and **other**,
1597- ///
1604+ #[ doc=$doc]
15981605 /// If their shapes disagree, **other** is broadcast to the shape of **self**.
15991606 ///
16001607 /// **Panics** if broadcasting isn't possible.
@@ -1624,14 +1631,22 @@ mod assign_ops {
16241631 } ;
16251632 }
16261633
1627- impl_assign_op ! ( AddAssign , add_assign) ;
1628- impl_assign_op ! ( SubAssign , sub_assign) ;
1629- impl_assign_op ! ( MulAssign , mul_assign) ;
1630- impl_assign_op ! ( DivAssign , div_assign) ;
1631- impl_assign_op ! ( RemAssign , rem_assign) ;
1632- impl_assign_op ! ( BitAndAssign , bitand_assign) ;
1633- impl_assign_op ! ( BitOrAssign , bitor_assign) ;
1634- impl_assign_op ! ( BitXorAssign , bitxor_assign) ;
1634+ impl_assign_op ! ( AddAssign , add_assign,
1635+ "Implement `self += other` as elementwise addition (in place).\n " ) ;
1636+ impl_assign_op ! ( SubAssign , sub_assign,
1637+ "Implement `self -= other` as elementwise subtraction (in place).\n " ) ;
1638+ impl_assign_op ! ( MulAssign , mul_assign,
1639+ "Implement `self *= other` as elementwise multiplication (in place).\n " ) ;
1640+ impl_assign_op ! ( DivAssign , div_assign,
1641+ "Implement `self /= other` as elementwise division (in place).\n " ) ;
1642+ impl_assign_op ! ( RemAssign , rem_assign,
1643+ "Implement `self %= other` as elementwise remainder (in place).\n " ) ;
1644+ impl_assign_op ! ( BitAndAssign , bitand_assign,
1645+ "Implement `self &= other` as elementwise bit and (in place).\n " ) ;
1646+ impl_assign_op ! ( BitOrAssign , bitor_assign,
1647+ "Implement `self |= other` as elementwise bit or (in place).\n " ) ;
1648+ impl_assign_op ! ( BitXorAssign , bitxor_assign,
1649+ "Implement `self ^= other` as elementwise bit xor (in place).\n " ) ;
16351650}
16361651
16371652impl < A : Clone + Neg < Output =A > , D : Dimension >
0 commit comments