Closed
Description
Summary
Hi, I am porting the "gl-matrix" to webassembly with wasm-bindgen. In "gl-matrix", we can find lots of those methods:
// module vec3
function add(out, a, b) {
xxx
}
In most time, arguments "out" and "a" are same variable.
I implement it in rust and have built it to wasm:
impl Vector3 {
pub fn add(out: &mut Vector3, a: &Vector3, b: &Vector3) {
xxx
}
}
It seems lt work fine, but after running these code:
const a = Vector3.create();
const b = Vector3.create();
Vector3.add(a, a, b);
Rust thrown an error:
debug.js:21 Error: recursive use of an object detected which would lead to unsafe aliasing in rust
Do you have any good idea to solve this problem? Thanks!