Debian Codegraph @

.cargo/vendor/wasm-bindgen/tests/wasm/comments.rs

raw
1 use wasm_bindgen::prelude::*;
2 use wasm_bindgen_test::*;
3
4 #[wasm_bindgen(module = "tests/wasm/comments.js")]
5 extern "C" {
6 fn assert_comments_exist();
7 }
8
9 /// annotated function ✔️ " \ ' {
10 #[wasm_bindgen]
11 pub fn annotated() -> String {
12 String::new()
13 }
14
15 /// annotated struct type
16 #[wasm_bindgen]
17 pub struct Annotated {
18 a: String,
19 /// annotated struct field b
20 pub b: u32,
21 /// annotated struct field c
22 #[wasm_bindgen(readonly)]
23 pub c: u32,
24 d: u32,
25 }
26
27 #[wasm_bindgen]
28 impl Annotated {
29 /// annotated struct constructor
30 #[wasm_bindgen(constructor)]
31 pub fn new() -> Self {
32 Self {
33 a: String::new(),
34 b: 0,
35 c: 0,
36 d: 0,
37 }
38 }
39
40 /// annotated struct method
41 pub fn get_a(&self) -> String {
42 self.a.clone()
43 }
44
45 /// annotated struct getter
46 #[wasm_bindgen(getter)]
47 pub fn d(&self) -> u32 {
48 self.d
49 }
50
51 /// annotated struct setter
52 #[wasm_bindgen(setter)]
53 pub fn set_d(&mut self, value: u32) {
54 self.d = value
55 }
56
57 /// annotated struct static method
58 pub fn static_method() {}
59 }
60
61 /// annotated enum type
62 #[wasm_bindgen]
63 pub enum AnnotatedEnum {
64 /// annotated enum variant 1
65 Variant1,
66 /// annotated enum variant 2
67 Variant2,
68 }
69
70 #[wasm_bindgen_test]
71 fn works() {
72 assert_comments_exist();
73 }