pub enum PairElement {
I32,
Bool,
Ratio,
Commodity,
StringRef,
Entity(EntityKind),
AnyRef,
}Expand description
Element type of a homogeneous $pair chain. Tracked at compile time so
CAR/CDR emit the right downcast and CONS refuses heterogeneous mixing
with a structured type error. Kept as a Copy enum so WasmType stays
Copy — and so adding a new element type stays a one-line variant
addition. Nesting (pairs-of-pairs) waits for a follow-up sub-slice
once flat lists are stable across the consumers.
Variants§
I32
Bool
Truth-value cell: shares I32’s i31-boxed car representation (CAR/CDR
emit the same i31 downcast), but distinct so a bool extracted from a
list serializes as Nil / Bool, not Number — the list-element
analogue of WasmType::Bool vs I32.
Ratio
Commodity
StringRef
Entity(EntityKind)
AnyRef
Heterogeneous escape hatch (ADR-0025). Cars stay as raw
anyref; CAR returns WasmType::AnyRef and the script must
downcast at the use site (or consume via type-test natives like
ok? / err-code). CONS widens to this variant when the two
arms disagree on element type, and host fns that produce
fundamentally heterogeneous lists (e.g. =catch-each= result
cells) construct directly into PairRef(AnyRef).
Implementations§
Source§impl PairElement
impl PairElement
Sourcepub fn as_wasm_type(self) -> WasmType
pub fn as_wasm_type(self) -> WasmType
The matching WasmType for a pair’s car when extracted.
Sourcepub fn from_wasm_type(ty: WasmType) -> Option<Self>
pub fn from_wasm_type(ty: WasmType) -> Option<Self>
Inverse of as_wasm_type: returns None if the given type can’t
ride a $pair’s anyref car. WasmType::AnyRef round-trips to
PairElement::AnyRef; nested pairs and closures still need their
own follow-up lattice extension.
Trait Implementations§
Source§impl Clone for PairElement
impl Clone for PairElement
Source§fn clone(&self) -> PairElement
fn clone(&self) -> PairElement
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more