pub struct FunctionType { /* private fields */ }Expand description
Function types classify the signature of functions, mapping a vector of parameters to a vector of results. They are also used to classify the inputs and outputs of instructions
See https://webassembly.github.io/spec/core/syntax/types.html#function-types
§Examples
§Input & Output
use wasm_ast::{FunctionType, ResultType};
let function_type = FunctionType::new(ResultType::empty(), ResultType::empty());
assert!(function_type.parameters().is_empty());
assert!(function_type.results().is_empty());§Input Only
use wasm_ast::{FunctionType, ResultType, ValueType};
let function_type = FunctionType::side_effect(ResultType::from(vec![ValueType::I32]));
assert_eq!(function_type.parameters().kinds(), &[ValueType::I32]);
assert!(function_type.results().is_empty());§Output Only
use wasm_ast::{FunctionType, ResultType, ValueType};
let function_type = FunctionType::nullary(ResultType::from(vec![ValueType::I32]));
assert!(function_type.parameters().is_empty());
assert_eq!(function_type.results().kinds(), &[ValueType::I32]);§No Input or Output
use wasm_ast::{FunctionType, ResultType, ValueType};
let function_type = FunctionType::runnable();
assert!(function_type.parameters().is_empty());
assert!(function_type.results().is_empty());Implementations§
Source§impl FunctionType
impl FunctionType
Sourcepub fn new(parameters: ResultType, results: ResultType) -> Self
pub fn new(parameters: ResultType, results: ResultType) -> Self
Creates a new function signature with the given parameter and result types.
Sourcepub fn side_effect(parameters: ResultType) -> Self
pub fn side_effect(parameters: ResultType) -> Self
Creates a new function signature with the given parameter types and no result types.
Sourcepub fn nullary(results: ResultType) -> Self
pub fn nullary(results: ResultType) -> Self
Creates a new function signature with the given result types and no parameter types.
Sourcepub fn runnable() -> Self
pub fn runnable() -> Self
Creates a new function signature with the no parameter or result types.
Sourcepub fn parameters(&self) -> &ResultType
pub fn parameters(&self) -> &ResultType
The parameter types of this FunctionType.
Sourcepub fn results(&self) -> &ResultType
pub fn results(&self) -> &ResultType
The result types of this FunctionType.
Trait Implementations§
Source§impl Clone for FunctionType
impl Clone for FunctionType
Source§fn clone(&self) -> FunctionType
fn clone(&self) -> FunctionType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FunctionType
impl Debug for FunctionType
Source§impl PartialEq for FunctionType
impl PartialEq for FunctionType
impl Eq for FunctionType
impl StructuralPartialEq for FunctionType
Auto Trait Implementations§
impl Freeze for FunctionType
impl RefUnwindSafe for FunctionType
impl Send for FunctionType
impl Sync for FunctionType
impl Unpin for FunctionType
impl UnwindSafe for FunctionType
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
Mutably borrows from an owned value. Read more