Skip to main content

TupleSchema

Struct TupleSchema 

Source
#[repr(C)]
pub struct TupleSchema { pub descriptors: &'static [*const TypeDescriptor], }
Expand description

The static shape of a tuple: an ordered list of element descriptors (positional, no names). Leaked to &'static once per distinct shape by the codegen.

A slot may be null, meaning the compiler had no static type for that element — the same honest encoding a Vec’s element descriptor already uses (var m = Map() generalizes at the var, so a program that never inspects the elements leaves them unresolved). The arity is still exact, so nothing is lost; the value’s own descriptor answers for a null slot, and it is read from the object’s header, so it is never wrong.

Fields§

§descriptors: &'static [*const TypeDescriptor]

Implementations§

Source§

impl TupleSchema

Source

pub fn arity(&self) -> usize

The number of elements in this tuple shape (its arity).

Source

pub fn same_shape(&self, other: &TupleSchema) -> bool

Whether two schemas describe the same tuple shape: equal arity and the same element descriptor in every slot.

Shape, not allocation identity. Schemas are interned per shape within a producer, but there are three producers — the codegen’s tuple_schema_for cache, the runtime’s point_schema, and the input parser — so two of them minting an (Int, Int) must still yield tuples that compare equal. Descriptors are static, so slot comparison is pointer comparison (ADR-038).

A null slot is unknown, not a fourth type: it agrees with whatever the other side says, and the values decide (see tuple_equals, which compares the two objects’ own descriptors for such a slot).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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