pub struct Type {
pub is_final: bool,
pub supertype: Option<TypeId>,
pub name: Option<String>,
/* private fields */
}Expand description
A WebAssembly type definition.
With the GC proposal, types can be function types, struct types, or array types, and can participate in subtyping and recursive type groups.
Fields§
§is_final: boolWhether this type is final (cannot be further subtyped).
Defaults to true for types without explicit subtype declarations.
supertype: Option<TypeId>Optional supertype that this type extends.
name: Option<String>An optional name for debugging.
This is not really used by anything currently, but a theoretical WAT to walrus parser could keep track of the original name in the WAT.
Implementations§
Source§impl Type
impl Type
Sourcepub fn kind(&self) -> &CompositeType
pub fn kind(&self) -> &CompositeType
Get a reference to the composite type.
Sourcepub fn kind_mut(&mut self) -> &mut CompositeType
pub fn kind_mut(&mut self) -> &mut CompositeType
Get a mutable reference to the composite type.
Sourcepub fn as_function(&self) -> Option<&FunctionType>
pub fn as_function(&self) -> Option<&FunctionType>
Returns this type’s composite type as a function type, if it is one.
Sourcepub fn as_struct(&self) -> Option<&StructType>
pub fn as_struct(&self) -> Option<&StructType>
Returns this type’s composite type as a struct type, if it is one.
Sourcepub fn as_array(&self) -> Option<&ArrayType>
pub fn as_array(&self) -> Option<&ArrayType>
Returns this type’s composite type as an array type, if it is one.
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Whether this type is a function type.
Sourcepub fn referenced_types(&self, out: &mut Vec<TypeId>)
pub fn referenced_types(&self, out: &mut Vec<TypeId>)
Collect all TypeIds that this type directly references.
This includes concrete heap types in parameters/results/fields and the supertype, if any. Used by the GC pass to transitively keep types alive.
Trait Implementations§
impl Eq for Type
Source§impl Ord for Type
impl Ord for Type
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.