Crates.io | dbgprint |
lib.rs | dbgprint |
version | 0.1.0 |
source | src |
created_at | 2023-07-03 13:59:16.582091 |
updated_at | 2023-07-03 13:59:16.582091 |
description | A set of macros that output the STDOUT and STDERR of the program only in debug mode. |
homepage | |
repository | |
max_upload_size | |
id | 907038 |
size | 5,254 |
This Rust library provides four simple macros for conditional printing in debug mode: dbgprint!
, dbgprintln!
, dbgeprint!
, dbgeprintln!
. These macros act as equivalents to print!
, println!
, eprint!
, eprintln!
respectively, but only produce output when the program is running in debug mode.
Here's an example of how you might use these macros in your code:
// In your Rust file...
// Print to stdout
dbgprint!("Hello, {}!", "world"); // prints "Hello, world!" in debug mode
dbgprintln!("Hello, {}!", "world"); // prints "Hello, world!\n" in debug mode
// Print to stderr
dbgeprint!("Error: {}", "something went wrong"); // prints "Error: something went wrong" to stderr in debug mode
dbgeprintln!("Error: {}", "something went wrong"); // prints "Error: something went wrong\n" to stderr in debug mode
Note that these macros will not produce any output when your program is compiled in release mode.
Add this to your Cargo.toml
:
[dependencies]
dbgprint = "0.1.0"
Then import the macros in your Rust files with:
use dbgprint::{dbgprint, dbgprintln, dbgeprint, dbgeprintln};
Bug reports and pull requests are welcome on GitHub at https://github.com/bwintertkb/dbgprint.
dbgprint
is distributed under the MIT and Apache-2.0 licenses.