pub struct ArrayType { /* private fields */ }Expand description
The type of a WebAssembly array.
WebAssembly arrays are dynamically-sized, but not resizable. They contain
either unpacked Vals 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 new ArrayType will be final and without a supertype.
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).
§Panics
Panics if the given field type is not associated with the given engine.
Sourcepub fn with_finality_and_supertype(
    engine: &Engine,
    finality: Finality,
    supertype: Option<&Self>,
    field_type: FieldType,
) -> Result<Self>
 
pub fn with_finality_and_supertype( engine: &Engine, finality: Finality, supertype: Option<&Self>, field_type: FieldType, ) -> Result<Self>
Construct a new StructType with the given finality, supertype, and
fields.
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 struct type that is associated with a different engine).
Returns an error if the supertype is final, or if this type does not match the supertype.
§Panics
Panics if the given field type is not associated with the given 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().
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArrayType
impl !RefUnwindSafe for ArrayType
impl Send for ArrayType
impl Sync for ArrayType
impl Unpin for ArrayType
impl !UnwindSafe for ArrayType
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<T> IntoEither for T
 
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
 
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
 
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more