pub enum Type {
    Primitive(PrimitiveType),
    Tuple(Vec<Type, Global>),
    Vector(Box<Type, Global>),
    Struct(ModuleId, StructId, Vec<Type, Global>),
    TypeParameter(u16),
    Reference(bool, Box<Type, Global>),
    Fun(Vec<Type, Global>, Box<Type, Global>),
    TypeDomain(Box<Type, Global>),
    ResourceDomain(ModuleId, StructId, Option<Vec<Type, Global>>),
    Error,
    Var(u16),
}
Expand description

Represents a type.

Variants§

§

Primitive(PrimitiveType)

§

Tuple(Vec<Type, Global>)

§

Vector(Box<Type, Global>)

§

Struct(ModuleId, StructId, Vec<Type, Global>)

§

TypeParameter(u16)

§

Reference(bool, Box<Type, Global>)

§

Fun(Vec<Type, Global>, Box<Type, Global>)

§

TypeDomain(Box<Type, Global>)

§

ResourceDomain(ModuleId, StructId, Option<Vec<Type, Global>>)

§

Error

§

Var(u16)

Implementations§

§

impl Type

pub fn new_prim(p: PrimitiveType) -> Type

pub fn is_type_parameter(&self) -> bool

Determines whether this is a type parameter.

pub fn is_reference(&self) -> bool

Determines whether this is a reference.

pub fn is_mutable_reference(&self) -> bool

Determines whether this is a mutable reference.

pub fn is_immutable_reference(&self) -> bool

Determines whether this is an immutable reference.

pub fn is_struct(&self) -> bool

Determines whether this type is a struct.

pub fn is_vector(&self) -> bool

Determines whether this type is a vector

pub fn is_struct_or_vector_of_struct(&self) -> bool

Determines whether this is a struct, or a vector of structs, or a reference to any of those.

pub fn is_spec(&self) -> bool

Returns true if this type is a specification language only type or contains specification language only types

pub fn is_number(&self) -> bool

Returns true if this is any number type.

pub fn is_signer_or_address(&self) -> bool

Returns true if this is an address or signer type.

pub fn is_address(&self) -> bool

Return true if this is an account address

pub fn is_signer(&self) -> bool

Return true if this is an account address

pub fn skip_reference(&self) -> &Type

Skip reference type.

pub fn replace_struct_instantiation(&self, inst: &[Type]) -> Type

If this is a struct type, replace the type instantiation.

pub fn get_struct<'env>( &'env self, env: &'env GlobalEnv ) -> Option<(StructEnv<'env>, &'env [Type])>

If this is a struct type, return the associated struct env and type parameters.

pub fn require_struct(&self) -> (ModuleId, StructId, &[Type])

Require this to be a struct, if so extracts its content.

pub fn instantiate(&self, params: &[Type]) -> Type

Instantiates type parameters in this type.

pub fn instantiate_vec( vec: Vec<Type, Global>, params: &[Type] ) -> Vec<Type, Global>

Instantiate type parameters in the vector of types.

pub fn instantiate_slice(slice: &[Type], params: &[Type]) -> Vec<Type, Global>

Instantiate type parameters in the slice of types.

pub fn type_param_map_to_inst( arity: usize, map: BTreeMap<u16, Type, Global> ) -> Vec<Type, Global>

Convert a partial assignment for type parameters into an instantiation.

pub fn contains<P>(&self, p: &P) -> boolwhere P: Fn(&Type) -> bool,

Checks whether this type contains a type for which the predicate is true.

pub fn is_incomplete(&self) -> bool

Returns true if this type is incomplete, i.e. contains any type variables.

pub fn is_open(&self) -> bool

Return true if this type contains generic types (i.e., types that can be instantiated).

pub fn module_usage(&self, usage: &mut BTreeSet<ModuleId, Global>)

Compute used modules in this type, adding them to the passed set.

pub fn into_struct_type(self, env: &GlobalEnv) -> Option<Type>

Attempt to convert this type into a normalized::Type

pub fn into_normalized_type(self, env: &GlobalEnv) -> Option<Type>

Attempt to convert this type into a normalized::Type

pub fn into_struct_tag(self, env: &GlobalEnv) -> Option<StructTag>

Attempt to convert this type into a language_storage::StructTag

pub fn into_type_tag(self, env: &GlobalEnv) -> Option<TypeTag>

Attempt to convert this type into a language_storage::TypeTag

pub fn from_type_tag(t: &TypeTag, env: &GlobalEnv) -> Type

Create a Type from t

pub fn get_vars(&self) -> BTreeSet<u16, Global>

Get the unbound type variables in the type.

pub fn visit<F>(&self, visitor: &mut F)where F: FnMut(&Type),

§

impl Type

pub fn display<'a>( &'a self, context: &'a TypeDisplayContext<'a> ) -> TypeDisplay<'a>

Trait Implementations§

§

impl Clone for Type

§

fn clone(&self) -> Type

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Type

§

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

Formats the value using the given formatter. Read more
§

impl Hash for Type

§

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
§

impl Ord for Type

§

fn cmp(&self, other: &Type) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
§

impl PartialEq<Type> for Type

§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl PartialOrd<Type> for Type

§

fn partial_cmp(&self, other: &Type) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Eq for Type

§

impl StructuralEq for Type

§

impl StructuralPartialEq for Type

Auto Trait Implementations§

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for Twhere T: Hash + ?Sized,

§

fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V