~ireas/public-inbox

[merge-rs] Various feature requests

Details
Message ID
<190e8ebf055.1852524630984.4399125530901819683@sunnymonster.co>
DKIM signature
pass
Download raw message
Hello,

I'm not sure if you are still maintaining this crate, but I have a few feature requests I'd like to make in case you are interested to add them.

- Derive for structs with lifetimes. Currently this is not possible and you have to manually implement the Merge trait for any structs with lifetimes. I think it would be a pretty simple fix to the derive macro.

- User-specified parameters to the merge function. Sometimes the merging of two structs require some additional parameters and there is currently no way of specifying one. In this case, I think modifying the merge trait to `Merge<P>` where P is any type could work. The merge function can then be changed to `fn merge(&mut self, other: Self, params: P)`. Although, in case of the derive macro, it might be a little bit more involved because there needs to be a way for the derive to pass in the parameter to the merge functions of the fields. Perhaps it could be done with another attribute? like `#[merge(merge_param = some_var)]` and maybe even `#[merge(merge_param = inherit)]` to inherit the parameter from the parent struct.

Please let me know if you are still interested in maintaining merge. If not, I would be more than happy to implement these changes in a fork and perhaps submit the patches.

Kind Regards
SunnyMonster
Reply to thread Export thread (mbox)