semi-automatic implementation proc-macro for binary operations `#[auto_ops]` make implementation for `T += U`, `T + U`, `T + &U`, `&T + U`, `&T + &U` from implementation for `T += &U`. supported list (`@` is `+`, `-`, `*`, `/`, `%`, `&`, `|`, `^`, `<<` or `>>`.) * `T @= &U` => `T @= U`, `&T @ &U`, `&T @ U`, `T @ &U`, `T @ U` * `T @= U` => `T @= &U`, `&T @ &U`, `&T @ U`, `T @ &U`, `T @ U` * `&T @ &U` => `T @= &U`, `T @= U`, `&T @ U`, `T @ &U`, `T @ U` * `&T @ U` => `T @= &U`, `T @= U`, `&T @ &U`, `T @ &U`, `T @ U` * `T @ &U` => `T @= &U`, `T @= U`, `&T @ &U`, `&T @ U`, `T @ U` * `T @ U` => `T @= &U`, `T @= U`, `&T @ U`, `T @ &U`, `T @ U` # Example ```rust use std::ops::*; # # #[derive(Clone, Default)] # struct A(T); #[auto_impl_ops::auto_ops] impl AddAssign<&A> for A where for<'x> &'x M: Add, { fn add_assign(&mut self, other: &Self) { self.0 = &self.0 + &other.0; } } ``` Above code is expanded into below code. For more examples see `examples/a.rs`. ```rust use std::ops::*; # # #[derive(Clone, Default)] # struct A(T); impl AddAssign<&A> for A where for<'x> &'x M: Add, { fn add_assign(&mut self, other: &Self) { self.0 = &self.0 + &other.0; } } #[allow(clippy::extra_unused_lifetimes)] impl AddAssign> for A where for<'x> &'x M: Add, { fn add_assign(&mut self, rhs: A) { let rhs = &rhs; self.add_assign(rhs); } } impl Add<&A> for &A where for<'x> &'x M: Add, A: Clone, { type Output = A; fn add(self, rhs: &A) -> Self::Output { let mut lhs = self.clone(); lhs.add_assign(rhs); lhs } } impl Add> for &A where for<'x> &'x M: Add, A: Clone, { type Output = A; fn add(self, rhs: A) -> Self::Output { let mut lhs = self.clone(); let rhs = &rhs; lhs.add_assign(rhs); lhs } } impl Add<&A> for A where for<'x> &'x M: Add, { type Output = A; fn add(self, rhs: &A) -> Self::Output { let mut lhs = self; lhs.add_assign(rhs); lhs } } #[allow(clippy::extra_unused_lifetimes)] impl Add> for A where for<'x> &'x M: Add, { type Output = A; fn add(self, rhs: A) -> Self::Output { let mut lhs = self; let rhs = &rhs; lhs.add_assign(rhs); lhs } } ``` # License `auto-impl-ops` is AGPL-3.0-or-later. The code generated by this proc-macro is exception of AGPL. You can choose its license as you like.