diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 23 |
1 files changed, 14 insertions, 9 deletions
@@ -1,17 +1,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 } -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } +#[wasm_bindgen] +pub fn test_alert(s: &str) { + alert(s) } |
