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.
NotData
An incomplete or erroneous type, which cannot be published.
Implementations§
Trait Implementations§
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.
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.
impl Eq for Type
Source§impl Hash for Type
Hashes each node’s kind, declaration and parameter in pre-order: equal
types hash alike.
impl Hash for Type
Hashes each node’s kind, declaration and parameter in pre-order: equal types hash alike.
Source§impl Nested for Type
impl Nested for Type
Source§fn parts(&self) -> impl DoubleEndedIterator<Item = &Type>
fn parts(&self) -> impl DoubleEndedIterator<Item = &Type>
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>
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
const LEAF: Type = Type::NotData
Source§fn same_tree(
&self,
other: &Self,
same_node: impl FnMut(&Self, &Self) -> bool,
) -> bool
fn same_tree( &self, other: &Self, same_node: impl FnMut(&Self, &Self) -> bool, ) -> bool
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)
fn free_parts(&mut self)
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.