Merge pull request #19 from ashleygwilliams/example
add js-hello-world example and take a path as an argmaster
commit
bd7d940ab0
@ -0,0 +1,13 @@ |
||||
[package] |
||||
name = "js-hello-world" |
||||
description = "an example rust->wasm crate" |
||||
version = "0.1.0" |
||||
authors = ["Ashley Williams <ashley666ashley@gmail.com>"] |
||||
license = "WTFPL" |
||||
repository = "https://github.com/ashleygwilliams/wasm-pack" |
||||
|
||||
[lib] |
||||
crate-type = ["cdylib"] |
||||
|
||||
[dependencies] |
||||
wasm-bindgen = { git = 'https://github.com/alexcrichton/wasm-bindgen' } |
@ -0,0 +1,16 @@ |
||||
#![feature(proc_macro)] |
||||
|
||||
extern crate wasm_bindgen; |
||||
|
||||
use wasm_bindgen::prelude::*; |
||||
|
||||
#[wasm_bindgen] |
||||
extern { |
||||
fn alert(s: &str); |
||||
} |
||||
|
||||
#[wasm_bindgen] |
||||
#[no_mangle] |
||||
pub extern fn greet(name: &str) { |
||||
alert(&format!("Hello, {}!", name)); |
||||
} |
Loading…
Reference in new issue