macro_rules! forward_ref_commutative_binop {
    (
        $( [ $($generic:tt)* ] )?
        impl Add for $lhs:ty, $rhs:ty
        $( where $($bound:tt)* )?
    ) => { ... };
    (
        $( [ $($generic:tt)* ] )?
        impl Mul for $lhs:ty, $rhs: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 commutatively (T binop U and U binop T), also implement T binop &U, &T binop U, &T binop &U, U binop &T, &U binop T and &U binop &T. This macro will fail if LHS = RHS.

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 generics
  • Trait is the trait to be implemented
  • Method is the method that Trait defines
    (can be ommitted for Add and Mul)
  • LHS is the type of the left hand side of the original operation (i.e. T)
  • RHS is the type of the right hand side of the original operation (i.e. U)
  • Bounds are comma-seperated trait bounds for the listed generics