Macro wasmer_runtime_core_x::imports
source · macro_rules! imports { ( $( $ns_name:expr => $ns:tt ),* $(,)? ) => { ... }; ($state_gen:expr, $( $ns_name:expr => $ns:tt ),* $(,)? ) => { ... }; }
Expand description
Generate an ImportObject
safely.
§Note
The import
macro currently only supports
importing functions.
§Usage
let import_object = imports! {
"env" => {
"foo" => func!(foo),
},
};
let imports_with_state = imports! {
|| (0 as _, |_a| {}),
"env" => {
"foo" => func!(foo),
},
};
fn foo(_: &mut Ctx, n: i32) -> i32 {
n
}