Add toDictionary procedure
This commit is contained in:
parent
1a0cb2be5c
commit
ea7225e3b5
|
@ -1,6 +1,6 @@
|
|||
# Package
|
||||
|
||||
version = "20230401"
|
||||
version = "20230403"
|
||||
author = "Emery Hemingway"
|
||||
description = "data model and serialization format"
|
||||
license = "Unlicense"
|
||||
|
|
|
@ -327,6 +327,11 @@ proc initSet*(E = void): Preserve[E] = Preserve[E](kind: pkSet)
|
|||
proc initDictionary*(E = void): Preserve[E] = Preserve[E](kind: pkDictionary)
|
||||
## Create a Preserves dictionary value.
|
||||
|
||||
proc toDictionary*[E](pairs: openArray[(string, Preserve[E])]): Preserve[E] =
|
||||
## Create a Preserves dictionary value.
|
||||
result = Preserve[E](kind: pkDictionary)
|
||||
for (key, val) in pairs: result[toSymbol(key, E)] = val
|
||||
|
||||
proc embed*[E](pr: sink Preserve[E]): Preserve[E] =
|
||||
## Create a Preserves value that embeds ``e``.
|
||||
result = pr
|
||||
|
|
Loading…
Reference in New Issue