macro_rules! forward_ref_binop {
(
$( [ $($generic:tt)* ] )?
impl Add for $lhs:ty $(, $rhs:ty )?
$( where $($bound:tt)* )?
) => { ... };
(
$( [ $($generic:tt)* ] )?
impl Sub for $lhs:ty $(, $rhs:ty )?
$( where $($bound:tt)* )?
) => { ... };
(
$( [ $($generic:tt)* ] )?
impl Mul for $lhs:ty $(, $rhs:ty )?
$( where $($bound:tt)* )?
) => { ... };
(
$( [ $($generic:tt)* ] )?
impl Div for $lhs:ty $(, $rhs:ty )?
$( where $($bound:tt)* )?
) => { ... };
(
$( [ $($generic:tt)* ] )?
impl $impl:ident, $meth:ident for $lhs:ty
$( where $($bound:tt)* )?
) => { ... };
(
$( [ $($generic:tt)* ] )?
impl $impl:ident, $meth:ident for $lhs:ty, $rhs:ty
$( where $($bound:tt)* )?
) => { ... };
}
Expand description
For types T: Copy
, U: Copy
for which binary operator binop
is implemented (T binop U
), also implement T binop &U
, &T binop U
and &T binop &U
.
For readability, the expected syntax of the macro is the following:
( [ Generics ] )?
impl Trait, Method for LHS(, RHS)?
( where Bounds )?
Generics
are comma-seperated type or const genericsTrait
is the trait to be implementedMethod
is the method thatTrait
defines
(can be ommitted forAdd
,Sub
,Mul
andDiv
)LHS
is the type of the left hand side of the operation (i.e.T
)RHS
is the type of the right hand side of the operation (i.e.U
)
if noRHS
is given,LHS
=RHS
is assumedBounds
are comma-seperated trait bounds for the listed generics