blob: 7129898a215f3d3a67870dcd831a4f8fce56f247 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
extern {
fn alert(s: &str);
// set the namespace so we can use ‘console.debug’
#[wasm_bindgen(js_namespace = console)]
fn debug(s: &str);
}
#[wasm_bindgen]
pub fn add(left: u32, right: u32) -> u32 {
debug(&format!("adding the numbers {} and {}",
left, right));
left + right
}
#[wasm_bindgen]
pub fn test_alert(s: &str) {
alert(s)
}
|