Skip to main content

Type

Enum Type 

Source
pub enum Type {
Show 20 variants Int, Decimal, Bool, Text, Bytes, Duration, Instant, Unit, Never, Json, List(Box<Type>), Set(Box<Type>), Dict(Box<Type>, Box<Type>), Option(Box<Type>), Tuple(Vec<Type>), Named(DeclId, Vec<Type>), Param(u32), Task(Box<Type>), Function { params: Vec<Type>, result: Box<Type>, }, NotData,
}
Expand description

A type, as the encoding sees it.

A type’s depth is not bounded: a polymorphically recursive function can nest one as deep as its run goes. So nothing here recurses on it past a few levels: it is a Nested tree, which cloning, substituting, hashing and judging fold and which compares and drops over a stack on the heap past those levels.

Variants§

§

Int

Int.

§

Decimal

Decimal.

§

Bool

Bool.

§

Text

Text.

§

Bytes

Bytes.

§

Duration

Duration.

§

Instant

Instant.

§

Unit

Unit.

§

Never

Never, which has no values.

§

Json

json.Value, which encodes as the JSON value it stands for.

§

List(Box<Type>)

List<T>.

§

Set(Box<Type>)

Set<T>.

§

Dict(Box<Type>, Box<Type>)

Dict<K, V>.

§

Option(Box<Type>)

Option<T>.

§

Tuple(Vec<Type>)

A tuple of two or more parts.

§

Named(DeclId, Vec<Type>)

A declared type, applied to its descriptive arguments.

§

Param(u32)

The nth type parameter of the declaration or signature it is written in.

§

Task(Box<Type>)

task.Task<T>, which has no encoding, except where a task is the id of the call it is parked on.

§

Function

A function, retained descriptively but without a value encoding.

Fields

§params: Vec<Type>

Its parameter types, in order.

§result: Box<Type>

Its result type.

§

NotData

An incomplete or erroneous type, which cannot be published.

Implementations§

Source§

impl Type

Source

pub fn head(&self) -> Head<'_>

This type’s head.

Source§

impl Type

Source

pub fn args(&self) -> &[Type]

The type arguments of a declared type, in order; none for any other type.

Source

pub fn list(item: Type) -> Type

List<item>.

Source

pub fn set(item: Type) -> Type

Set<item>.

Source

pub fn dict(key: Type, value: Type) -> Type

Dict<key, value>.

Source

pub fn option(item: Type) -> Type

Option<item>.

Source

pub fn subst(&self, args: &[Type]) -> Type

This type with each Type::Param replaced by the argument at its position. A parameter with no argument is left as it is.

Source

pub fn map_parts(&self, part: impl FnMut(&Type) -> Type) -> Type

A node of self’s kind whose parts are what part makes of its own, each once, in Nested::parts order: what a Fold that makes a type joins a node with.

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Type

Source§

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

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

impl Drop for Type

Dropping a type frees its nested parts first: the first few levels by native recursion, and anything deeper over a stack on the heap, so a type nested however deep drops on a native stack of fixed size.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Type

Source§

impl Hash for Type

Hashes each node’s kind, declaration and parameter in pre-order: equal types hash alike.

Source§

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

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 Nested for Type

Source§

fn parts(&self) -> impl DoubleEndedIterator

The types self is made of, in order: an item, a key and a value, a tuple’s parts, a declared type’s arguments, or a function type’s parameters and then its result.

Source§

fn parts_mut(&mut self) -> impl Iterator<Item = &mut Type>

The types self is made of, in Nested::parts order, for moving out.

Source§

const LEAF: Type = Type::NotData

A node with no parts, left in a part’s place when it is moved out.
Source§

fn fold<F>(&self, fold: &mut F) -> <F as Fold<Self>>::Made
where F: Fold<Self>,

What fold makes of self, built bottom-up. Read more
Source§

fn same_tree( &self, other: &Self, same_node: impl FnMut(&Self, &Self) -> bool, ) -> bool

Whether self and other are alike node by node, by same_node, which says whether two nodes are alike on their own, with as many parts: with each node’s count of parts, pre-order spells the tree.
Source§

fn free_parts(&mut self)

Frees each part only self holds that has parts of its own, leaving Nested::LEAF in its place: what dropping self does first, so a tree nested however deep drops on a native stack of fixed size.
Source§

impl PartialEq for Type

Two types are equal when their nodes, read in pre-order, are alike one by one: with each node’s count of parts, that order spells the tree.

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Forget for Type

§

impl Freeze for Type
where *const Type is !null: Freeze, PhantomData<Type>: Freeze, *const u8 is !null: Freeze,

§

impl Move for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type
where BoxRaw<Type>: Send, RawVecInner: Send,

§

impl Sync for Type
where BoxRaw<Type>: Sync, RawVecInner: Sync,

§

impl Unpin for Type
where Box<Type>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Type

§

impl UnwindSafe for Type
where BoxRaw<Type>: UnwindSafe, RawVecInner: UnwindSafe,

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.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.