Enum move_model::ty::Type

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

Represents a type.

Variants§

§

Primitive(PrimitiveType)

§

Tuple(Vec<Type>)

§

Vector(Box<Type>)

§

Struct(ModuleId, StructId, Vec<Type>)

§

TypeParameter(u16)

§

Reference(bool, Box<Type>)

§

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

§

TypeDomain(Box<Type>)

§

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

§

Error

§

Var(u16)

Implementations§

source§

impl Type

source

pub fn new_prim(p: PrimitiveType) -> Type

source

pub fn is_type_parameter(&self) -> bool

Determines whether this is a type parameter.

source

pub fn is_reference(&self) -> bool

Determines whether this is a reference.

source

pub fn is_mutable_reference(&self) -> bool

Determines whether this is a mutable reference.

source

pub fn is_immutable_reference(&self) -> bool

Determines whether this is an immutable reference.

source

pub fn is_struct(&self) -> bool

Determines whether this type is a struct.

source

pub fn is_vector(&self) -> bool

Determines whether this type is a vector

source

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.

source

pub fn is_spec(&self) -> bool

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

source

pub fn is_number(&self) -> bool

Returns true if this is any number type.

source

pub fn is_signer_or_address(&self) -> bool

Returns true if this is an address or signer type.

source

pub fn is_address(&self) -> bool

Return true if this is an account address

source

pub fn is_signer(&self) -> bool

Return true if this is an account address

source

pub fn skip_reference(&self) -> &Type

Skip reference type.

source

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

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

source

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.

source

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

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

source

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

Instantiates type parameters in this type.

source

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

Instantiate type parameters in the vector of types.

source

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

Instantiate type parameters in the slice of types.

source

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

Convert a partial assignment for type parameters into an instantiation.

source

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.

source

pub fn is_incomplete(&self) -> bool

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

source

pub fn is_open(&self) -> bool

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

source

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

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

source

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

Attempt to convert this type into a normalized::Type

source

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

Attempt to convert this type into a normalized::Type

source

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

Attempt to convert this type into a language_storage::StructTag

source

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

Attempt to convert this type into a language_storage::TypeTag

source

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

Create a Type from t

source

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

Get the unbound type variables in the type.

source

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

source§

impl Type

source

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

Trait Implementations§

source§

impl Clone for Type

source§

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
source§

impl Debug for Type

source§

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

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

impl Hash for Type

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

source§

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
source§

impl PartialEq<Type> for Type

source§

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.
source§

impl PartialOrd<Type> for Type

source§

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
source§

impl Eq for Type

source§

impl StructuralEq for Type

source§

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