Add isRecord(…) with arity descriminator

This commit is contained in:
Emery Hemingway 2023-03-29 16:47:54 -05:00
parent 786342c39b
commit 5d3f7b94a3
1 changed files with 6 additions and 0 deletions

View File

@ -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.