pub struct FuncType { /* private fields */ }
runtime
only.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§
source§impl FuncType
impl FuncType
sourcepub 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 descriptor from the given parameters and results.
The function descriptor returned will represent a function which takes
params
as arguments and returns results
when it is finished.
sourcepub 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.
sourcepub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
pub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Returns the list of parameter types for this function.
sourcepub 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.
sourcepub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
pub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Returns the list of result types for this function.