carbotaniuman / auto_ops

Macros for overloading operators easily in Rust.
MIT License
34 stars 9 forks source link

assignment operator for mutable referance #3

Closed pathammer closed 3 years ago

pathammer commented 4 years ago

How would you suggest using this macro to generate assignment operators for &mut types? It currently only generates impl's for straight values and not references.

Thanks!

let mut dk = DonkeyKong::new(4);
let dk = &mut dk.clone();
dk += DonkeyKong::new(1);  // compile error, no impl
assert_eq!(DonkeyKong::new(6), dk);
carbotaniuman commented 3 years ago

You can get around this by manually dereferencing dk. primitive types don't support this operation, so I think this it out of scope for this repository.