mahjong_core/log.rs
1use wasm_bindgen::prelude::wasm_bindgen;
2
3#[wasm_bindgen]
4extern "C" {
5 // Use `js_namespace` here to bind `console.log(..)` instead of just
6 // `log(..)`
7 #[wasm_bindgen(js_namespace = console)]
8 pub fn log(s: &str);
9
10 // The `console.log` is quite polymorphic, so we can bind it with multiple
11 // signatures. Note that we need to use `js_name` to ensure we always call
12 // `log` in JS.
13 #[wasm_bindgen(js_namespace = console, js_name = log)]
14 pub fn log_u32(a: u32);
15
16 // Multiple arguments too!
17 #[wasm_bindgen(js_namespace = console, js_name = log)]
18 pub fn log_many(a: &str, b: &str);
19}