Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyuwoo-choi/ee1a34f022726ab9cb96fde2b798a281 to your computer and use it in GitHub Desktop.
Save kyuwoo-choi/ee1a34f022726ab9cb96fde2b798a281 to your computer and use it in GitHub Desktop.
// Rust
#[wasm_bindgen]
pub struct Foo {
contents: u32,
}
#[wasm_bindgen]
impl Foo {
pub fn new() -> Foo {
Foo { contents: 0 }
}
pub fn add(&mut self, amt: u32) -> u32 {
self.contents += amt;
return self.contents
}
}
// JS
import { Foo } from "./js_hello_world";
let foo = Foo.new();
assertEq(foo.add(10), 10);
foo.free();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment