Fix bug and un-deprecate Instance::call

This commit is contained in:
Mark McCaskey 2020-03-31 14:06:30 -07:00
parent 836711f7cd
commit bde319d9fb
2 changed files with 19 additions and 6 deletions

View File

@ -230,6 +230,23 @@ impl Instance {
/// This returns `CallResult<Vec<Value>>` in order to support
/// the future multi-value returns WebAssembly feature.
///
/// Consider using the more explicit [`Exports::get`]` with [`DynFunc::call`]
/// instead. For example:
///
/// ```
/// # use wasmer_runtime_core::types::Value;
/// # use wasmer_runtime_core::error::Result;
/// # use wasmer_runtime_core::Instance;
/// # use wasmer_runtime_core::DynFunc;
/// # fn call_foo(instance: &mut Instance) -> Result<()> {
/// // ...
/// let foo: DynFunc = instance.exports.get("foo")?;
/// let results = foo.call(&[Value::I32(42)])?;
/// // ...
/// # Ok(())
/// # }
/// ```
///
/// # Usage:
/// ```
/// # use wasmer_runtime_core::types::Value;
@ -242,10 +259,6 @@ impl Instance {
/// # Ok(())
/// # }
/// ```
#[deprecated(
since = "0.17.0",
note = "Please use `let f: DynFunc = instance.exports.get(name)?; f.call(params)?;` instead"
)]
pub fn call(&self, name: &str, params: &[Value]) -> CallResult<Vec<Value>> {
let func: DynFunc = self.exports.get(name)?;
func.call(params)

View File

@ -180,14 +180,14 @@ impl Module {
/// // For example, here we get all the names of the functions exported by this module.
/// let function_names =
/// module.exports()
/// .filter(|ed| ed.kind == ExportType::Function)
/// .filter(|ed| ed.ty == ExportType::Function)
/// .map(|ed| ed.name.to_string())
/// .collect::<Vec<String>>();
///
/// // And here we count the number of global variables exported by this module.
/// let num_globals =
/// module.exports()
/// .filter(|ed| ed.kind == ExportType::Global)
/// .filter(|ed| ed.ty == ExportType::Global)
/// .count();
/// # }
/// ```