//! debug_print.rs //! //! This module provides macros for conditional debug printing. These macros only output content //! during debug builds (e.g., when running `cargo build` or `cargo run`). In release builds //! (e.g., `cargo build --release` or `cargo run --release`), the print statements are completely //! omitted by the compiler, ensuring no performance overhead or unnecessary output in production. //! //! This is useful for debugging purposes, such as logging intermediate values or states during //! development, without affecting the final release binary. //! //! # Usage //! //! - Use `dprint!` and `dprintln!` for standard output (stdout). //! - Use `deprint!` and `deprintln!` for standard error (stderr). //! //! These macros support the same formatting syntax as Rust's built-in `print!`, `println!`, //! `eprint!`, and `eprintln!` macros. //! //! # Example //! //! ```rust //! dprintln!("This will only print in debug mode: {}", some_value); //! deprint!("Error-like message to stderr in debug: {}", error_code); //! ``` //! //! Note: These macros rely on the `#[cfg(debug_assertions)]` attribute, which is enabled by default //! in debug builds and disabled in release builds. // Prints formatted output to standard output (stdout) only in debug builds. #[macro_export] macro_rules! dprint { ($($arg:tt)*) => (#[cfg(debug_assertions)] print!($($arg)*)); } // Prints formatted output to standard output (stdout) followed by a newline, only in debug builds. #[macro_export] macro_rules! dprintln { ($($arg:tt)*) => (#[cfg(debug_assertions)] println!($($arg)*)); } // Prints formatted output to standard error (stderr) only in debug builds. #[macro_export] macro_rules! deprint { ($($arg:tt)*) => (#[cfg(debug_assertions)] eprint!($($arg)*)); } // Prints formatted output to standard error (stderr) followed by a newline, only in debug builds. #[macro_export] macro_rules! deprintln { ($($arg:tt)*) => (#[cfg(debug_assertions)] eprintln!($($arg)*)); }