Skip to content

Commit c2d212b

Browse files
committed
get rid of Wasmi warning
1 parent 95a4c1c commit c2d212b

File tree

2 files changed

+10
-12
lines changed
  • dist/canister_templates
  • src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly

2 files changed

+10
-12
lines changed
7.29 KB
Binary file not shown.

src/experimental/build/commands/build/wasm_binary/rust/experimental_canister_template/src/web_assembly/instantiate.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,7 @@ impl JsFn for NativeFunction {
1818
panic!("conversion from JsValue to JsArrayBuffer failed")
1919
};
2020

21-
let engine = wasmi::Engine::default();
22-
let module = wasmi::Module::new(&engine, &mut &wasm_bytes[..]).unwrap();
23-
24-
let linker = <wasmi::Linker<()>>::new(&engine);
25-
26-
let mut store = wasmi::Store::new(&engine, ());
27-
28-
let instance = linker
29-
.instantiate(&mut store, &module)
30-
.unwrap()
31-
.start(&mut store)
32-
.unwrap();
21+
let (instance, mut store) = instantiate_wasm_module(&wasm_bytes);
3322

3423
let mut exports_js_object = context.new_object();
3524

@@ -193,3 +182,12 @@ impl JsFn for NativeFunction {
193182
instantiated_source_js_object.into()
194183
}
195184
}
185+
186+
fn instantiate_wasm_module(wasm_bytes: &[u8]) -> (wasmi::Instance, wasmi::Store<()>) {
187+
let engine = wasmi::Engine::default();
188+
let module = wasmi::Module::new(&engine, &mut &wasm_bytes[..]).unwrap();
189+
let linker = <wasmi::Linker<()>>::new(&engine);
190+
let mut store = wasmi::Store::new(&engine, ());
191+
let instance = linker.instantiate_and_start(&mut store, &module).unwrap();
192+
(instance, store)
193+
}

0 commit comments

Comments
 (0)