Add integer converter

This commit is contained in:
Emery Hemingway 2024-04-22 11:08:11 +02:00
parent 8d48ae60e9
commit ea698bedcc
2 changed files with 4 additions and 1 deletions

View File

@ -1,6 +1,6 @@
# Package
version = "20240312"
version = "20240422"
author = "Emery Hemingway"
description = "data model and serialization format"
license = "Unlicense"

View File

@ -335,6 +335,9 @@ template unpreservable*() {.pragma.}
## as its native type.
## Unpreservability is asserted at runtime.
converter preserve*(i: SomeInteger): Value =
Value(kind: pkRegister, register: BiggestInt i)
proc toPreserves*[T](x: T): Value {.gcsafe.} =
## Serializes ``x`` to Preserves. Can be customized by defining
## ``toPreservesHook(x: T; E: typedesc)`` in the calling scope.