Simplify examples: avoid unnecessary HostRef wrap/unwrap
Several of the examples wrap the Instance in a HostRef, only to immediately borrow it again to get the exports,and then never touch it again. Simplify this by owning the Instance directly.
This commit is contained in:
committed by
Jakub Konka
parent
204b4d376a
commit
7c8ac3d71c
@@ -55,13 +55,10 @@ fn main() -> Result<()> {
|
||||
.0;
|
||||
|
||||
// Instantiate the module.
|
||||
let instance = HostRef::new(Instance::new(&store, &module, &[])?);
|
||||
let instance = Instance::new(&store, &module, &[])?;
|
||||
|
||||
// Invoke `gcd` export
|
||||
let gcd = instance.borrow().exports()[gcd_index]
|
||||
.func()
|
||||
.expect("gcd")
|
||||
.clone();
|
||||
let gcd = instance.exports()[gcd_index].func().expect("gcd").clone();
|
||||
let result = gcd
|
||||
.borrow()
|
||||
.call(&[Val::from(6i32), Val::from(27i32)])
|
||||
|
||||
Reference in New Issue
Block a user