123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #[allow(unused_macros)]
- macro_rules! dbg_log {
- ($fmt:expr) => {
- println!($fmt);
- };
- ($fmt:expr, $($arg:tt)*) => {
- println!($fmt, $($arg)*);
- }
- }
- #[allow(unused_macros)]
- macro_rules! dbg_assert {
- ($($arg:tt)*) => {
- debug_assert!($($arg)*);
- };
- }
- #[cfg(target_arch = "wasm32")]
- #[allow(unused_macros)]
- macro_rules! dbg_log {
- ($fmt:expr) => {
- {
- use ::util::{ DEBUG, _log_to_js_console };
- if DEBUG { _log_to_js_console($fmt); }
- }
- };
- ($fmt:expr, $($arg:tt)*) => {
- {
- use ::util::{ DEBUG, _log_to_js_console };
- if DEBUG { _log_to_js_console(format!($fmt, $($arg)*)); }
- }
- };
- }
- #[cfg(target_arch = "wasm32")]
- #[allow(unused_macros)]
- macro_rules! dbg_assert {
- ($cond:expr) => {{
- use util::{_log_to_js_console, abort, DEBUG};
- if DEBUG && !$cond {
- _log_to_js_console(format!(
- "Assertion failed at {}:{}:{}: '{}'",
- file!(),
- line!(),
- column!(),
- stringify!($cond),
- ));
- unsafe {
- abort();
- }
- }
- }};
- ($cond:expr, $desc:expr) => {{
- use util::{_log_to_js_console, abort, DEBUG};
- if DEBUG && !$cond {
- _log_to_js_console(format!(
- "Assertion failed at {}:{}:{}: '{}' - '{}'",
- file!(),
- line!(),
- column!(),
- stringify!($cond),
- $desc,
- ));
- unsafe {
- abort();
- }
- }
- }};
- }
|