summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: 5f8c602e60b28829f461615d44a98da9efc843a1 (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]
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)
}