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
Example
```rust
use std::ops::*;
#[derive(Clone, Default)]
struct A(T);
[autoimplops::auto_ops]
impl AddAssign<&A> for A
where
for<'x> &'x M: Add
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<'a, M> AddAssign<&'a A> for A
where
for<'x> &'x M: Add
[allow(clippy::extraunusedlifetimes)]
impl<'a, M> AddAssign> for A
where
for<'x> &'x M: Add
[allow(clippy::extraunusedlifetimes)]
impl<'a, M> Add> for A
where
for<'x> &'x M: Add,
{
type Output = Self;
fn add(mut self, rhs: A) -> Self::Output {
self.add_assign(&rhs);
self
}
}
```
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.