From 5d3f7b94a38c4a8159eebe512d2150352668861c Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 29 Mar 2023 16:47:54 -0500 Subject: [PATCH] =?UTF-8?q?Add=20isRecord(=E2=80=A6)=20with=20arity=20desc?= =?UTF-8?q?riminator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/preserves.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/preserves.nim b/src/preserves.nim index b9478de..cfcf016 100644 --- a/src/preserves.nim +++ b/src/preserves.nim @@ -411,6 +411,12 @@ func isRecord*(pr: Preserve; label: string): bool {.inline.} = pr.record.len > 0 and pr.label.isSymbol(label) +func isRecord*(pr: Preserve; label: string; arity: Natural): bool {.inline.} = + ## Check if ``pr`` is a Preserves record with the given label symbol and field arity. + pr.kind == pkRecord and + pr.record.len == succ(arity) and + pr.label.isSymbol(label) + proc isSequence*(pr: Preserve): bool {.inline.} = pr.kind == pkSequence ## Check if ``pr`` is a Preserves sequence.