From f0c1ebe85e66619bc0cd2e7dcd8d621ab8b0f30a Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Fri, 9 Jul 2021 12:24:51 +0200 Subject: [PATCH] Add isNil for Preserve Not a ref type, but add `isNil` for checking if a Perserve is zero-initialized. --- src/preserves.nim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/preserves.nim b/src/preserves.nim index 7e0fe09..a06f765 100644 --- a/src/preserves.nim +++ b/src/preserves.nim @@ -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]: