Sha256: d54246efce5d7a104702439ba509bcc5bfbb0b57253edebdb696617daca80bcd
Contents?: true
Size: 561 Bytes
Versions: 30
Compression:
Stored size: 561 Bytes
Contents
# `method` The `method` attribute allows you to describe methods of imported JavaScript objects. It is applied on a function that has `this` as its first parameter, which is a shared reference to an imported JavaScript type. ```rust #[wasm_bindgen] extern "C" { type Set; #[wasm_bindgen(method)] fn has(this: &Set, element: &JsValue) -> bool; } ``` This generates a `has` method on `Set` in Rust, which invokes the `Set.prototype.has` method in JavaScript. ```rust let set: Set = ...; let elem: JsValue = ...; if set.has(&elem) { ... } ```
Version data entries
30 entries across 30 versions & 1 rubygems