mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-28 07:51:07 +00:00
Merge pull request #1011 from alexcrichton/import-doc
Add a note about renaming types and `js_class`
This commit is contained in:
commit
7a528d4b6b
@ -44,3 +44,18 @@ extern {
|
|||||||
|
|
||||||
All of these functions will call `console.log` in JavaScript, but each
|
All of these functions will call `console.log` in JavaScript, but each
|
||||||
identifier will have only one signature in Rust.
|
identifier will have only one signature in Rust.
|
||||||
|
|
||||||
|
Note that if you use `js_name` when importing a type you'll also need to use the
|
||||||
|
[`js_class` attribute][jsclass] when defining methods on the type:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern {
|
||||||
|
#[wasm_bindgen(js_name = String)]
|
||||||
|
type JsString;
|
||||||
|
#[wasm_bindgen(method, getter, js_class = "String")]
|
||||||
|
pub fn length(this: &JsString) -> u32;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[jsclass]: js_class.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user