Merge pull request #48 from ashleygwilliams/readme-oops

fix(doc): update readme code example
master
ashley williams 7 years ago committed by GitHub
commit 96acdb873e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      README.md

@ -57,19 +57,18 @@ this project is written in rust. [get rust] to work on this project.
use wasm_bindgen::prelude::*;
```
4. annotate your public functions with `#[wasm_bindgen]` and `#[no_mangle]`, for example:
4. annotate your public functions with `#[wasm_bindgen]`, for example:
```rust
#[wasm_bindgen]
extern {
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
}
#[wasm_bindgen]
#[no_mangle]
pub extern fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
#[wasm_bindgen]
pub fn greet(name: &str) {
alert(&format!("Hello, {}!", name));
}
```
5. install this tool: `cargo install wasm-pack`

Loading…
Cancel
Save