For example, can I do something like this?
Some.js
let foo = {num: 1};
rust_add_one_to_foo(foo);
console.log(foo) // {num: 2}
I was reading the wasm-bindgen
docs, and this looked like what I wanted at first:
https://rustwasm.github.io/docs/wasm-bindgen/reference/types/pointers.html
But my initial tests to add one failed, even if foo
was just an integer. Here was my rust code for that:
pub fn add_one(num: *mut u8) {
unsafe {
*num += 1;
}
}