def is_keyed

bend-schema-lib@0.4.1.0 · core.bend:1805

import bend-schema-lib@0.4.1.0/core.bend as Core
import Base

1805# A record chain (ending in SEnd) or a variant chain (ending in SVEnd): what
1806# SStrict may wrap, so every key its encoding writes is a declared name.
1807# A chain of keys (SField or SVariant links, ending in SEnd or SVEnd): what
1808# SStrict may wrap, so every key its encoding writes is a name it declares.
1809def is_keyed(s: Schema) -> Bool:
1810  match s:
1811    case SField{n, fs, rest}:
1812      is_keyed(rest)
1813    case SEnd{}:
1814      True{}
1815    case SVariant{n, vs, rest}:
1816      is_keyed(rest)
1817    case SVEnd{}:
1818      True{}
1819    case _:
1820      False{}

Uses (2)

Used by (1)