Skip to content

Commit

Permalink
Merge pull request #3490 from nicolas-albert/patch-1
Browse files Browse the repository at this point in the history
Fix JS sample code by adding "&mut store"
  • Loading branch information
syrusakbary authored Jan 26, 2023
2 parents 59d2d90 + 7ab9eb2 commit 26bde69
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@
//! to compile it with [`wasm-pack`] and [`wasm-bindgen`]:
//!
//! ```ignore
//! use wasm_bindgen::prelude::*;
//! use wasmer::{imports, Instance, Module, Store, Value};
//!
//! #[wasm_bindgen]
//! pub extern fn do_add_one_in_wasmer() -> i32 {
//! let module_wat = r#"
Expand All @@ -382,10 +385,10 @@
//! let module = Module::new(&store, &module_wat).unwrap();
//! // The module doesn't import anything, so we create an empty import object.
//! let import_object = imports! {};
//! let instance = Instance::new(&module, &import_object).unwrap();
//! let instance = Instance::new(&mut store, &module, &import_object).unwrap();
//!
//! let add_one = instance.exports.get_function("add_one").unwrap();
//! let result = add_one.call(&[Value::I32(42)]).unwrap();
//! let result = add_one.call(&mut store, &[Value::I32(42)]).unwrap();
//! assert_eq!(result[0], Value::I32(43));
//!
//! result[0].unwrap_i32()
Expand Down

0 comments on commit 26bde69

Please sign in to comment.