PhilippMDoerner/mapster

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?

  1. 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

  1. merge config items for Config system

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.

nim-lang/Nim#22676

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.