Alternative for derive-merge-struct crate?

Hey,
how do you merge data from one struct to another struct of same type?
So to say replacing/overwriting existing field data values, depending on the values.

I've found the crate https://crates.io/crates/derive-merge-struct/.
But it doesn't seem to be used much.
So the question rises, how you do this?

Are you looking for .. syntax?

1 Like

No, not looking for the update syntax...
What I'm looking for is exactly what derive-merge-struct does when calling target.merge_proto(&source).
See the short readme on the crates page.

If it does exactly what you need then I think the way to do this is to use it or to manually write the function. There's nothing built-in in Rust for it in any case. I'd guess the reason it's not used much is that this kind of merge operation isn't that common.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.