average icon indicating copy to clipboard operation
average copied to clipboard

Impls and derive for Merge trait

Open xmakro opened this issue 2 years ago • 1 comments

It would be useful if Merge was implemented for common containers such as HashMap and if it could be derived for structs.

#[derive(Default, Merge)
struct A {
  hello: Mean,
  world: HashMap<String, Max>,
}

let mut x = A::default();
let y = A::default();
x.merge(y);

I'm happy to send a PR if you agree with this. It might require a new crate average_derive for the derive macros.

xmakro avatar Aug 30 '22 16:08 xmakro

Indeed, supporting derive would be more user-friendly than the current macros and makes sense.

Implementing Merge for containers is an interesting idea, I need to think a bit about the semantics.

vks avatar Oct 05 '22 21:10 vks