Enum ValType
pub enum ValType {
I32,
I64,
F32,
F64,
V128,
Ref(RefType),
}
Expand description
A list of all possible value types in WebAssembly.
§Subtyping and Equality
ValType
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
ValType::matches
and Val::matches_ty
methods
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 ValType::eq
method.
Variants§
I32
Signed 32 bit integer.
I64
Signed 64 bit integer.
F32
Floating point 32 bit integer.
F64
Floating point 64 bit integer.
V128
A 128 bit number.
Ref(RefType)
An opaque reference to some type on the heap.
Implementations§
§impl ValType
impl ValType
pub const NULLEXTERNREF: ValType = _
pub const NULLEXTERNREF: ValType = _
The nullexternref
type, aka (ref null noextern)
.
pub const NULLFUNCREF: ValType = _
pub const NULLFUNCREF: ValType = _
The nullfuncref
type, aka (ref null nofunc)
.
pub fn is_num(&self) -> bool
pub fn is_num(&self) -> bool
Returns true if ValType
matches any of the numeric types. (e.g. I32
,
I64
, F32
, F64
).
pub fn is_funcref(&self) -> bool
pub fn is_funcref(&self) -> bool
Is this the funcref
(aka (ref null func)
) type?
pub fn is_externref(&self) -> bool
pub fn is_externref(&self) -> bool
Is this the externref
(aka (ref null extern)
) type?
pub fn as_ref(&self) -> Option<&RefType>
pub fn as_ref(&self) -> Option<&RefType>
Get the underlying reference type, if this value type is a reference type.
pub fn unwrap_ref(&self) -> &RefType
pub fn unwrap_ref(&self) -> &RefType
Get the underlying reference type, panicking if this value type is not a reference type.
Trait Implementations§
§impl From<ValType> for StorageType
impl From<ValType> for StorageType
§fn from(v: ValType) -> StorageType
fn from(v: ValType) -> StorageType
Auto Trait Implementations§
impl Freeze for ValType
impl !RefUnwindSafe for ValType
impl Send for ValType
impl Sync for ValType
impl Unpin for ValType
impl !UnwindSafe for ValType
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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