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§
Source§impl FuncType
impl FuncType
Sourcepub fn new(
engine: &Engine,
params: impl IntoIterator<Item = ValType>,
results: impl IntoIterator<Item = ValType>,
) -> FuncType
Available on crate feature runtime only.
pub fn new( engine: &Engine, params: impl IntoIterator<Item = ValType>, results: impl IntoIterator<Item = ValType>, ) -> FuncType
runtime only.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 engine(&self) -> &Engine
Available on crate feature runtime only.
pub fn engine(&self) -> &Engine
runtime only.Get the engine that this function type is associated with.
Sourcepub fn param(&self, i: usize) -> Option<ValType>
Available on crate feature runtime only.
pub fn param(&self, i: usize) -> Option<ValType>
runtime only.Get the ith parameter type.
Returns None if i is out of bounds.
Sourcepub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Available on crate feature runtime only.
pub fn params(&self) -> impl ExactSizeIterator<Item = ValType> + '_
runtime only.Returns the list of parameter types for this function.
Sourcepub fn result(&self, i: usize) -> Option<ValType>
Available on crate feature runtime only.
pub fn result(&self, i: usize) -> Option<ValType>
runtime only.Get the ith result type.
Returns None if i is out of bounds.
Sourcepub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
Available on crate feature runtime only.
pub fn results(&self) -> impl ExactSizeIterator<Item = ValType> + '_
runtime only.Returns the list of result types for this function.
Sourcepub fn matches(&self, other: &FuncType) -> bool
Available on crate feature runtime only.
pub fn matches(&self, other: &FuncType) -> bool
runtime only.Does this function type match the other function type?
That is, is this function type a subtype of the other function type?
§Panics
Panics if either type is associated with a different engine from the other.
Sourcepub fn eq(a: &FuncType, b: &FuncType) -> bool
Available on crate feature runtime only.
pub fn eq(a: &FuncType, b: &FuncType) -> bool
runtime only.Is function type a precisely equal to function type b?
Returns false even if a is a subtype of b or vice versa, if they
are not exactly the same function type.
§Panics
Panics if either type is associated with a different engine from the other.
Trait Implementations§
Source§impl From<FuncType> for ExternType
Available on crate feature runtime only.
impl From<FuncType> for ExternType
runtime only.Source§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§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