pub enum PairElement {
I32,
Bool,
Ratio,
Commodity,
StringRef,
Symbol,
Entity(EntityKind),
Struct(StructId),
Closure(ClosureSigId),
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
Symbol
Runtime symbol or keyword: a $symbol struct carrying its printed name.
Entity(EntityKind)
Struct(StructId)
A DEFSTRUCT instance of this layout: a $struct reference.
Closure(ClosureSigId)
A closure of this signature: a closure struct reference.
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: None for a nested list, which has no
slot of its own. WasmType::AnyRef round-trips to PairElement::AnyRef.
Trait Implementations§
Source§impl Clone for PairElement
impl Clone for PairElement
impl Copy for PairElement
Source§impl Debug for PairElement
impl Debug for PairElement
Source§impl Display for PairElement
impl Display for PairElement
impl Eq for PairElement
Source§impl Hash for PairElement
impl Hash for PairElement
Source§impl Ord for PairElement
impl Ord for PairElement
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PairElement
impl PartialEq for PairElement
Source§impl PartialOrd for PairElement
impl PartialOrd for PairElement
impl StructuralPartialEq for PairElement
Auto Trait Implementations§
impl Freeze for PairElement
impl RefUnwindSafe for PairElement
impl Send for PairElement
impl Sync for PairElement
impl Unpin for PairElement
impl UnsafeUnpin for PairElement
impl UnwindSafe for PairElement
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.