feat: update examples

This commit is contained in:
2023-01-18 23:57:29 +08:00
parent d514f80f64
commit 3eefa3cba1
3 changed files with 54 additions and 28 deletions

View File

@@ -38,11 +38,11 @@ fn main() -> Result<()> {
// println!("memory size: {}", memory.size(&store));
let msg = "hatter".as_bytes();
let malloc_fn = instance.get_typed_func::<i32, i32, _>(&mut store, "__wbindgen_malloc")?;
let malloc_fn = instance.get_typed_func::<i32, i32>(&mut store, "__wbindgen_malloc")?;
let msg_ptr = malloc_fn.call(&mut store, msg.len() as i32)?;
memory.write(&mut store, msg_ptr as usize, msg)?;
let greet_fn = instance.get_typed_func::<(i32, i32), (), _>(&mut store, "greet")?;
let greet_fn = instance.get_typed_func::<(i32, i32), ()>(&mut store, "greet")?;
greet_fn.call(&mut store, (msg_ptr, msg.len() as i32))?;
Ok(())