mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
[examples] duck-typed-interfaces - port to rust 2018
This commit is contained in:
parent
7107a896da
commit
573c14118a
@ -2,6 +2,7 @@
|
|||||||
name = "rust-duck-typed-interfaces"
|
name = "rust-duck-typed-interfaces"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["The wasm-bindgen Developers"]
|
authors = ["The wasm-bindgen Developers"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
extern crate wasm_bindgen;
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
/// Here is a duck-typed interface for any JavaScript object that has a `quack`
|
/// Here is a duck-typed interface for any JavaScript object that has a `quack`
|
||||||
@ -18,6 +17,6 @@ extern "C" {
|
|||||||
/// Next, we can export a function that takes any object that quacks:
|
/// Next, we can export a function that takes any object that quacks:
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn make_em_quack_to_this(duck: &Quacks) {
|
pub fn make_em_quack_to_this(duck: &Quacks) {
|
||||||
let s = duck.quack();
|
let _s = duck.quack();
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user