Skip to main content

PairElement

Enum PairElement 

Source
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

Source

pub fn as_wasm_type(self) -> WasmType

The matching WasmType for a pair’s car when extracted.

Source

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.

Source

pub fn widen(self, other: Self) -> Self

Widen self against other to the most-specific common element. Identical types stay; everything else widens to AnyRef so heterogeneous CONS no longer errors. Symmetric.

Trait Implementations§

Source§

impl Clone for PairElement

Source§

fn clone(&self) -> PairElement

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PairElement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PairElement

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for PairElement

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PairElement

Source§

fn eq(&self, other: &PairElement) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PairElement

Source§

impl Eq for PairElement

Source§

impl StructuralPartialEq for PairElement

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,