#[cfg(debug_assertions)] macro_rules! debug { () => (std::println!()); ($($arg:tt)*) => ({ println!($($arg)*); }) } #[cfg(not(debug_assertions))] macro_rules! debug { () => {}; ($($arg:tt)*) => {}; } fn main() { debug!("debug"); debug!("debug {} {} {:?}", 1, 2, 3); }
可以不加 () => (std::println!());