symcode_webapp/util.rs
1use std::fmt::Display;
2
3use web_sys::console;
4
5extern crate cfg_if;
6
7cfg_if::cfg_if! {
8 // When the `console_error_panic_hook` feature is enabled, we can call the
9 // `set_panic_hook` function to get better error messages if we ever panic.
10 if #[cfg(feature = "console_error_panic_hook")] {
11 extern crate console_error_panic_hook;
12 pub use self::console_error_panic_hook::set_once as set_panic_hook;
13 } else {
14 #[inline]
15 pub fn set_panic_hook() {}
16 }
17}
18
19pub(crate) fn console_log_util<T>(content: T)
20where T: Display
21{
22 console::log_1(&content.to_string().into());
23}