pub struct ArrayType { /* private fields */ }
runtime
only.Expand description
The type of a WebAssembly array.
WebAssembly arrays are dynamically-sized, but not resizable. They contain
either unpacked Val
s or packed 8-/16-bit integers.
§Subtyping and Equality
ArrayType
does not implement Eq
, because reference types have a
subtyping relationship, and so 99.99% of the time you actually want to check
whether one type matches (i.e. is a subtype of) another type. You can use
the ArrayType::matches
method to perform these types of checks. If,
however, you are in that 0.01% scenario where you need to check precise
equality between types, you can use the ArrayType::eq
method.
Implementations§
source§impl ArrayType
impl ArrayType
sourcepub fn new(engine: &Engine, field_type: FieldType) -> Self
pub fn new(engine: &Engine, field_type: FieldType) -> Self
Construct a new ArrayType
with the given field type’s mutability and
storage type.
The result will be associated with the given engine, and attempts to use it with other engines will panic (for example, checking whether it is a subtype of another array type that is associated with a different engine).
sourcepub fn field_type(&self) -> FieldType
pub fn field_type(&self) -> FieldType
Get this array’s underlying field type.
The field type contains information about both this array type’s mutability and the storage type used for its elements.
sourcepub fn mutability(&self) -> Mutability
pub fn mutability(&self) -> Mutability
Get this array type’s mutability and whether its instances’ elements can be updated or not.
This is a convenience method providing a short-hand for
my_array_type.field_type().mutability()
.
sourcepub fn element_type(&self) -> StorageType
pub fn element_type(&self) -> StorageType
Get the storage type used for this array type’s elements.
This is a convenience method providing a short-hand for
my_array_type.field_type().element_type()
.