Fix toPreserveHook for Table[A, B]
The toPreserveHook for tables was not compiling, which would fall back to the behavior for preserving objects, which would not work for tables.
This commit is contained in:
parent
7edc05a35d
commit
dae5dd9751
|
@ -574,8 +574,8 @@ proc toPreserveHook*[T](set: HashSet[T]): Preserve =
|
|||
|
||||
proc toPreserveHook*[A, B](table: Table[A, B]|TableRef[A, B]): Preserve =
|
||||
## Hook for preserving ``Table``.
|
||||
result = Preserve(kind: pkDictionary, dict: initTable[Preserve, Preserve](table.len))
|
||||
for k, v in table.pairs: result.dict.add((k.toPreserve, v.toPreserve, ))
|
||||
result = initDictionary()
|
||||
for k, v in table.pairs: result[k.toPreserve] = v.toPreserve
|
||||
|
||||
proc fromPreserve*[T](v: var T; pr: Preserve): bool =
|
||||
## Inplace version of `preserveTo`. Returns ``true`` on
|
||||
|
|
Loading…
Reference in New Issue