File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
guide/src/reference/attributes/on-js-imports Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -11,11 +11,16 @@ name (like a class or function name) it'll be accessed through this namespace.
11
11
extern " C" {
12
12
#[wasm_bindgen(js_namespace = console)]
13
13
fn log (s : & str );
14
+
15
+ type Foo ;
16
+ #[wasm_bindgen(constructor, js_namespace = Bar )]
17
+ fn new () -> Foo ;
14
18
}
15
19
16
20
log (" hello, console!" );
21
+ Foo :: new ();
17
22
```
18
23
19
- This is an example of how to bind ` console.log ` in Rust. The ` log ` function will
20
- be available in the Rust module and will be invoked as ` console.log ` in
24
+ This is an example of how to bind namespaced items in Rust. The ` log ` and ` Foo::new ` functions will
25
+ be available in the Rust module and will be invoked as ` console.log ` and ` new Bar.Foo ` in
21
26
JavaScript.
You can’t perform that action at this time.
0 commit comments