console_log macro upgrade
This commit is contained in:
@@ -14,21 +14,37 @@ use crate::MizeError;
|
|||||||
use crate::core::item::IntoItemData;
|
use crate::core::item::IntoItemData;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// console_log macro
|
// console_log macro
|
||||||
|
// that can be copied into other files for debugging purposes
|
||||||
|
#[cfg(feature = "wasm-target")]
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "wasm-target")]
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[wasm_bindgen(js_namespace = console)]
|
#[wasm_bindgen(js_namespace = console)]
|
||||||
fn log(s: &str);
|
fn log(s: &str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "wasm-target")]
|
||||||
macro_rules! console_log {
|
macro_rules! console_log {
|
||||||
// Note that this is using the `log` function imported above during
|
// Note that this is using the `log` function imported above during
|
||||||
// `bare_bones`
|
// `bare_bones`
|
||||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
($($t:tt)*) => (unsafe { log(&format_args!($($t)*).to_string())})
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(not(feature = "wasm-target"))]
|
||||||
|
macro_rules! console_log {
|
||||||
|
// Note that this is using the `log` function imported above during
|
||||||
|
// `bare_bones`
|
||||||
|
($($t:tt)*) => ()
|
||||||
}
|
}
|
||||||
//end of console_log macro
|
//end of console_log macro
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
|
||||||
// allocator.
|
// allocator.
|
||||||
#[cfg(feature = "wee_alloc")]
|
#[cfg(feature = "wee_alloc")]
|
||||||
|
|||||||
Reference in New Issue
Block a user