deno_bindgen icon indicating copy to clipboard operation
deno_bindgen copied to clipboard

[wip] feat: implement "object wraps"

Open littledivy opened this issue 3 years ago • 1 comments
trafficstars

Closes #63

Rust structs as JavaScript classes. Prior art: wasm_bindgen & napi-rs.

pub struct NonSerializable {
  inner: i32,
}

#[deno_bindgen]
impl NonSerializable {
  pub fn add(&mut self, a: i32) {
    self.inner += a;
  }
  
  #[deno_bindgen(constructor)]
  pub fn new() -> Self {
    Self { inner: 0 }
  }
}
import { NonSerializable } from "./bindings/bindings.ts";
const ptr = new NonSerializable();
ptr.add(10)

littledivy avatar Mar 25 '22 17:03 littledivy

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 25 '22 17:03 CLAassistant

Hi @littledivy, why was this closed?

jkomyno avatar Jul 20 '23 15:07 jkomyno