unsplat component::Linker::func_wrap args (#5065)
* component::Linker::func_wrap: replace IntoComponentFunc with directly accepting a closure We find that this makes the Linker::func_wrap type signature much easier to read. The IntoComponentFunc abstraction was adding a lot of weight to "splat" a set of arguments from a tuple of types into individual arguments to the closure. Additionally, making the StoreContextMut argument optional, or the Result<return> optional, wasn't very worthwhile. * Fixes for the new style of closure required by component::Linker::func_wrap * fix fuzzing generator
This commit is contained in:
@@ -95,7 +95,7 @@ fn nested_many_instantiations() -> Result<()> {
|
||||
let mut linker = Linker::new(&engine);
|
||||
linker
|
||||
.root()
|
||||
.func_wrap("count", |mut store: StoreContextMut<'_, u32>| {
|
||||
.func_wrap("count", |mut store: StoreContextMut<'_, u32>, _: ()| {
|
||||
*store.data_mut() += 1;
|
||||
Ok(())
|
||||
})?;
|
||||
@@ -162,7 +162,7 @@ fn thread_options_through_inner() -> Result<()> {
|
||||
let mut linker = Linker::new(&engine);
|
||||
linker
|
||||
.root()
|
||||
.func_wrap("hostfn", |param: u32| Ok((param.to_string(),)))?;
|
||||
.func_wrap("hostfn", |_, (param,): (u32,)| Ok((param.to_string(),)))?;
|
||||
let instance = linker.instantiate(&mut store, &component)?;
|
||||
let result = instance
|
||||
.get_typed_func::<(u32,), (WasmStr,), _>(&mut store, "run")?
|
||||
|
||||
Reference in New Issue
Block a user