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:
@@ -48,11 +48,13 @@ pub fn link_spectest<T>(linker: &mut Linker<T>, store: &mut Store<T>) -> Result<
|
||||
#[cfg(feature = "component-model")]
|
||||
pub fn link_component_spectest<T>(linker: &mut component::Linker<T>) -> Result<()> {
|
||||
let engine = linker.engine().clone();
|
||||
linker.root().func_wrap("host-return-two", || Ok((2u32,)))?;
|
||||
linker
|
||||
.root()
|
||||
.func_wrap("host-return-two", |_, _: ()| Ok((2u32,)))?;
|
||||
let mut i = linker.instance("host")?;
|
||||
i.func_wrap("return-three", || Ok((3u32,)))?;
|
||||
i.func_wrap("return-three", |_, _: ()| Ok((3u32,)))?;
|
||||
i.instance("nested")?
|
||||
.func_wrap("return-four", || Ok((4u32,)))?;
|
||||
.func_wrap("return-four", |_, _: ()| Ok((4u32,)))?;
|
||||
|
||||
let module = Module::new(
|
||||
&engine,
|
||||
|
||||
Reference in New Issue
Block a user