Implement a js_name customization

This'll allow binding multiple signatures of a JS function as well as otherwise
changing the name of the JS function you're calling from the Rust function that
you're defining.

Closes #72
This commit is contained in:
Alex Crichton
2018-03-22 19:05:14 -07:00
parent a8045fbbe9
commit 7ebc428646
10 changed files with 155 additions and 66 deletions

View File

@ -8,9 +8,15 @@ use wasm_bindgen::prelude::*;
extern {
#[wasm_bindgen(js_namespace = console)]
fn log(s: &str);
#[wasm_bindgen(js_namespace = console, js_name = log)]
fn log_u32(a: u32);
#[wasm_bindgen(js_namespace = console, js_name = log)]
fn log_many(a: &str, b: &str);
}
#[wasm_bindgen]
pub fn run() {
log("Hello from Rust!");
log_u32(42);
log_many("Logging", "many values!");
}