denoland / deno_bindgen

Write high-level Deno FFI libraries in Rust.
MIT License
274 stars 28 forks source link

Support TypedArray types... #144

Open nearest-river opened 8 months ago

nearest-river commented 8 months ago

TypedArrays are very helpful in certain situations... for example a Vec<i32> or a Box<[i32]> could be turned into an Int32Array which is very helpful

Rust

#[deno_bindgen]
pub fn mouse_pos(this: usize)-> Box<[i32]> {
  let this=unsafe { ..... };
  let pos=this.mouse_position();
  vec![pos.x,pos.y].into_boxed_slice()
}

denoland

export function mouse_pos(self: number|bigint): Int32Array {
  return lib.symbols.mouse_pos(self);
}