diff --git a/src/macros.rs b/src/macros.rs index 2d27e951b6bcd4f6cace5a6df3824f08d3aa3957..7777d1438c26ff8c770480bee68c179d5490e364 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,3 +1,5 @@ +// Utility for performing debug printing within a particular module. Still +// requires some extra macros to be defined to be ergonomic. macro_rules! enabled_debug_print { (false, $name:literal, $format:literal) => {}; (false, $name:literal, $format:literal, $($args:expr),*) => {}; @@ -7,4 +9,13 @@ macro_rules! enabled_debug_print { (true, $name:literal, $format:literal, $($args:expr),*) => { println!("[{}] {}", $name, format!($format, $($args),*)) }; +} + +// Utility for inserting code only executed in debug mode. Because writing the +// conditional cfg is tedious and looks ugly. Still doesn't work for struct +// fields, though. +macro_rules! dbg_code { + ($code:stmt) => { + #[cfg(debug_assertions)] $code + } } \ No newline at end of file