Remove explicit S type from component functions (#5722)

I ended up forgetting this as part of #5275.
This commit is contained in:
Alex Crichton
2023-02-06 16:07:57 -06:00
committed by GitHub
parent 939b6ea933
commit 284fec127a
11 changed files with 216 additions and 225 deletions

View File

@@ -173,7 +173,7 @@ macro_rules! define_static_api_test {
let mut store: Store<Box<dyn Any>> = Store::new(&engine, Box::new(()));
let instance = linker.instantiate(&mut store, &component).unwrap();
let func = instance
.get_typed_func::<($($param,)*), R, _>(&mut store, EXPORT_FUNCTION)
.get_typed_func::<($($param,)*), R>(&mut store, EXPORT_FUNCTION)
.unwrap();
while input.arbitrary()? {

View File

@@ -185,7 +185,7 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, store: &mut Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(), (), _>(&store)?;
/// let typed = func.typed::<(), ()>(&store)?;
/// typed.call(store, ())?;
/// # Ok(())
/// # }
@@ -198,7 +198,7 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(&str,), (String,), _>(&store)?;
/// let typed = func.typed::<(&str,), (String,)>(&store)?;
/// let ret = typed.call(&mut store, ("Hello, ",))?.0;
/// println!("returned string was: {}", ret);
/// # Ok(())
@@ -211,17 +211,16 @@ impl Func {
/// # use wasmtime::component::Func;
/// # use wasmtime::Store;
/// # fn foo(func: &Func, mut store: Store<()>) -> anyhow::Result<()> {
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,), _>(&store)?;
/// let typed = func.typed::<(u32, Option<&str>, &[u8]), (bool,)>(&store)?;
/// let ok: bool = typed.call(&mut store, (1, Some("hello"), b"bytes!"))?.0;
/// println!("return value was: {ok}");
/// # Ok(())
/// # }
/// ```
pub fn typed<Params, Return, S>(&self, store: S) -> Result<TypedFunc<Params, Return>>
pub fn typed<Params, Return>(&self, store: impl AsContext) -> Result<TypedFunc<Params, Return>>
where
Params: ComponentNamedList + Lower,
Return: ComponentNamedList + Lift,
S: AsContext,
{
self._typed(store.as_context().0)
}

View File

@@ -85,20 +85,19 @@ impl Instance {
/// # Panics
///
/// Panics if `store` does not own this instance.
pub fn get_typed_func<Params, Results, S>(
pub fn get_typed_func<Params, Results>(
&self,
mut store: S,
mut store: impl AsContextMut,
name: &str,
) -> Result<TypedFunc<Params, Results>>
where
Params: ComponentNamedList + Lower,
Results: ComponentNamedList + Lift,
S: AsContextMut,
{
let f = self
.get_func(store.as_context_mut(), name)
.ok_or_else(|| anyhow!("failed to find function export `{}`", name))?;
Ok(f.typed::<Params, Results, _>(store)
Ok(f.typed::<Params, Results>(store)
.with_context(|| format!("failed to convert function `{}` to given type", name))?)
}