Created
June 3, 2018 17:16
-
-
Save kyuwoo-choi/ee1a34f022726ab9cb96fde2b798a281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Rust | |
#[wasm_bindgen] | |
pub struct Foo { | |
contents: u32, | |
} | |
#[wasm_bindgen] | |
impl Foo { | |
pub fn new() -> Foo { | |
Foo { contents: 0 } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn add(&mut self, amt: u32) -> u32 { | |
self.contents += amt; | |
return self.contents | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JS | |
import { Foo } from "./js_hello_world"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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