Is there a function of merging two object
lost22git opened this issue · 5 comments
someting like :
type A = object
name: string
type B = object
name: string
proc merge(a: var A, b: B): discard
Not so far as the package was conceived on functional grounds to map
(aka convert) an instance of A to an instance of B.
I have a rough idea on what your reasons might be, but could you type out explicitly why you'd want to merge instead of map?
- edit entities and save them to db for web backend app
EntityEdit -> Find Entiry by EntityEdit.id -> merge EntityEdit into Entity -> save Entity to db
- merge config items for Config system
Similar functionality from the java world
https://mapstruct.org/documentation/stable/reference/html/#updating-bean-instances
Looks like an interesting thing to have. I'll see that I get the testing finished. It'll have to be called inplaceMap
as merge
as a keyword is taken by nim.
Feature has been added and is available in the latest version of mapster with v1.1.0.
There it is called inplaceMap
as well as inplaceMapExcept
.
I have not written any docs for it yet, but given that this thing is becoming feature rich enough it might be valid to start a nimibook for it anyway.