Add isNil for Preserve

Not a ref type, but add `isNil` for checking if a Perserve is
zero-initialized.
This commit is contained in:
Emery Hemingway 2021-07-09 12:24:51 +02:00
parent 8985060055
commit f0c1ebe85e
1 changed files with 4 additions and 0 deletions

View File

@ -59,6 +59,10 @@ proc assertValid*(prs: Preserve) =
else:
discard
proc isNil*(prs: Preserve): bool =
## Check if ``prs`` is equivalent to the zero-initialized ``Preserve``.
prs.kind == pkBoolean and prs.bool == false
proc `<`(x, y: string | seq[byte]): bool =
for i in 0 .. min(x.high, y.high):
if x[i] < y[i]: