1 use wasm_bindgen::prelude::*; 2 use wasm_bindgen_test::*; 3 4 #[wasm_bindgen(module = "tests/wasm/structural.js")] 5 extern "C" { js_works()6 fn js_works(); 7 } 8 9 #[wasm_bindgen] 10 extern "C" { 11 pub type StructuralFoo; 12 13 #[wasm_bindgen(method, structural)] bar(this: &StructuralFoo)14 fn bar(this: &StructuralFoo); 15 #[wasm_bindgen(method, getter, structural)] baz(this: &StructuralFoo) -> u3216 fn baz(this: &StructuralFoo) -> u32; 17 #[wasm_bindgen(method, setter, structural)] set_baz(this: &StructuralFoo, val: u32)18 fn set_baz(this: &StructuralFoo, val: u32); 19 } 20 21 #[wasm_bindgen] run(a: &StructuralFoo)22pub fn run(a: &StructuralFoo) { 23 a.bar(); 24 assert_eq!(a.baz(), 1); 25 a.set_baz(2); 26 assert_eq!(a.baz(), 2); 27 } 28 29 #[wasm_bindgen_test] works()30fn works() { 31 js_works(); 32 } 33