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
impl Type
pub fn new_prim(p: PrimitiveType) -> Type
sourcepub fn is_type_parameter(&self) -> bool
pub fn is_type_parameter(&self) -> bool
Determines whether this is a type parameter.
sourcepub fn is_reference(&self) -> bool
pub fn is_reference(&self) -> bool
Determines whether this is a reference.
sourcepub fn is_mutable_reference(&self) -> bool
pub fn is_mutable_reference(&self) -> bool
Determines whether this is a mutable reference.
sourcepub fn is_immutable_reference(&self) -> bool
pub fn is_immutable_reference(&self) -> bool
Determines whether this is an immutable reference.
sourcepub fn is_struct_or_vector_of_struct(&self) -> bool
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.
sourcepub fn is_spec(&self) -> bool
pub fn is_spec(&self) -> bool
Returns true if this type is a specification language only type or contains specification language only types
sourcepub fn is_signer_or_address(&self) -> bool
pub fn is_signer_or_address(&self) -> bool
Returns true if this is an address or signer type.
sourcepub fn is_address(&self) -> bool
pub fn is_address(&self) -> bool
Return true if this is an account address
sourcepub fn skip_reference(&self) -> &Type
pub fn skip_reference(&self) -> &Type
Skip reference type.
sourcepub fn replace_struct_instantiation(&self, inst: &[Type]) -> Type
pub fn replace_struct_instantiation(&self, inst: &[Type]) -> Type
If this is a struct type, replace the type instantiation.
sourcepub fn get_struct<'env>(
&'env self,
env: &'env GlobalEnv
) -> Option<(StructEnv<'env>, &'env [Type])>
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.
sourcepub fn require_struct(&self) -> (ModuleId, StructId, &[Type])
pub fn require_struct(&self) -> (ModuleId, StructId, &[Type])
Require this to be a struct, if so extracts its content.
sourcepub fn instantiate(&self, params: &[Type]) -> Type
pub fn instantiate(&self, params: &[Type]) -> Type
Instantiates type parameters in this type.
sourcepub fn instantiate_vec(vec: Vec<Type>, params: &[Type]) -> Vec<Type> ⓘ
pub fn instantiate_vec(vec: Vec<Type>, params: &[Type]) -> Vec<Type> ⓘ
Instantiate type parameters in the vector of types.
sourcepub fn instantiate_slice(slice: &[Type], params: &[Type]) -> Vec<Type> ⓘ
pub fn instantiate_slice(slice: &[Type], params: &[Type]) -> Vec<Type> ⓘ
Instantiate type parameters in the slice of types.
sourcepub fn type_param_map_to_inst(
arity: usize,
map: BTreeMap<u16, Type>
) -> Vec<Type> ⓘ
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.
sourcepub fn contains<P>(&self, p: &P) -> boolwhere
P: Fn(&Type) -> bool,
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.
sourcepub fn is_incomplete(&self) -> bool
pub fn is_incomplete(&self) -> bool
Returns true if this type is incomplete, i.e. contains any type variables.
sourcepub fn is_open(&self) -> bool
pub fn is_open(&self) -> bool
Return true if this type contains generic types (i.e., types that can be instantiated).
sourcepub fn module_usage(&self, usage: &mut BTreeSet<ModuleId>)
pub fn module_usage(&self, usage: &mut BTreeSet<ModuleId>)
Compute used modules in this type, adding them to the passed set.
sourcepub fn into_struct_type(self, env: &GlobalEnv) -> Option<MType>
pub fn into_struct_type(self, env: &GlobalEnv) -> Option<MType>
Attempt to convert this type into a normalized::Type
sourcepub fn into_normalized_type(self, env: &GlobalEnv) -> Option<MType>
pub fn into_normalized_type(self, env: &GlobalEnv) -> Option<MType>
Attempt to convert this type into a normalized::Type
sourcepub fn into_struct_tag(self, env: &GlobalEnv) -> Option<StructTag>
pub fn into_struct_tag(self, env: &GlobalEnv) -> Option<StructTag>
Attempt to convert this type into a language_storage::StructTag
sourcepub fn into_type_tag(self, env: &GlobalEnv) -> Option<TypeTag>
pub fn into_type_tag(self, env: &GlobalEnv) -> Option<TypeTag>
Attempt to convert this type into a language_storage::TypeTag
sourcepub fn from_type_tag(t: &TypeTag, env: &GlobalEnv) -> Self
pub fn from_type_tag(t: &TypeTag, env: &GlobalEnv) -> Self
Create a Type
from t
pub fn visit<F: FnMut(&Type)>(&self, visitor: &mut F)
source§impl Type
impl Type
pub fn display<'a>( &'a self, context: &'a TypeDisplayContext<'a> ) -> TypeDisplay<'a>
Trait Implementations§
source§impl Ord for Type
impl Ord for Type
source§impl PartialEq<Type> for Type
impl PartialEq<Type> for Type
source§impl PartialOrd<Type> for Type
impl PartialOrd<Type> for Type
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl 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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.