Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/examples/closures.md

raw
1 # web-sys: Closures
2
3 [View full source code][code] or [view the compiled example online][online]
4
5 [online]: https://rustwasm.github.io/wasm-bindgen/exbuild/closures/
6 [code]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/closures
7
8 One of the features of `#[wasm_bindgen]` is that you can pass closures defined
9 in Rust off to JS. This can be a bit tricky at times, though, so the example
10 here shows how to interact with some standard web APIs with closures.
11
12 ## `src/lib.rs`
13
14 ```rust
15 {{#include ../../../examples/closures/src/lib.rs}}
16 ```