Struct FuncType
pub struct FuncType { /* private fields */ }
Expand description
The type of a WebAssembly function.
WebAssembly functions can have 0 or more parameters and results.
§Subtyping and Equality
FuncType
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
FuncType::matches
and Func::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 FuncType::eq
method.
Implementations§
§impl FuncType
impl FuncType
pub fn new(
engine: &Engine,
params: impl IntoIterator<Item = ValType>,
results: impl IntoIterator<Item = ValType>,
) -> FuncType
pub fn new( engine: &Engine, params: impl IntoIterator<Item = ValType>, results: impl IntoIterator<Item = ValType>, ) -> FuncType
Creates a new function type from the given parameters and results.
The function type returned will represent a function which takes
params
as arguments and returns results
when it is finished.
The resulting function type will be final and without a supertype.
§Panics
Panics if any parameter or value type is not associated with the given engine.
pub fn with_finality_and_supertype(
engine: &Engine,
finality: Finality,
supertype: Option<&FuncType>,
params: impl IntoIterator<Item = ValType>,
results: impl IntoIterator<Item = ValType>,
) -> Result<FuncType, Error>
pub fn with_finality_and_supertype( engine: &Engine, finality: Finality, supertype: Option<&FuncType>, params: impl IntoIterator<Item = ValType>, results: impl IntoIterator<Item = ValType>, ) -> Result<FuncType, Error>
Create a new function type with the given finality, supertype, parameter types, and result types.
Returns an error if the supertype is final, or if this function type does not match the supertype.
§Panics
Panics if any parameter or value type is not associated with the given engine.
pub fn param(&self, i: usize) -> Option<ValType>
pub fn param(&self, i: usize) -> Option<ValType>
Get the i
th parameter type.
Returns None
if i
is out of bounds.
pub fn params(&self) -> impl ExactSizeIterator
pub fn params(&self) -> impl ExactSizeIterator
Returns the list of parameter types for this function.
pub fn result(&self, i: usize) -> Option<ValType>
pub fn result(&self, i: usize) -> Option<ValType>
Get the i
th result type.
Returns None
if i
is out of bounds.
pub fn results(&self) -> impl ExactSizeIterator
pub fn results(&self) -> impl ExactSizeIterator
Returns the list of result types for this function.
Trait Implementations§
§impl From<FuncType> for ExternType
impl From<FuncType> for ExternType
§fn from(ty: FuncType) -> ExternType
fn from(ty: FuncType) -> ExternType
Auto Trait Implementations§
impl Freeze for FuncType
impl !RefUnwindSafe for FuncType
impl Send for FuncType
impl Sync for FuncType
impl Unpin for FuncType
impl !UnwindSafe for FuncType
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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