Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A struct will show up as a class on the JS side of things
- extern crate wasm_bindgen;
- use wasm_bindgen::prelude::*;
- #[wasm_bindgen]
- pub struct Bar {
- contents: String,
- }
- #[wasm_bindgen]
- impl Bar {
- #[wasm_bindgen(constructor)]
- pub fn new() -> Bar {
- Bar {
- contents: "Maximilian".to_string()
- }
- }
- #[wasm_bindgen]
- pub fn name(&self) -> String {
- self.contents.clone()
- }
- }
Add Comment
Please, Sign In to add comment