Function debug

Source
pub fn debug(message: &str)
Expand description

Print the given message if the DEBUG environment variable is set.

§Example

use debug_message::debug;

println!("this will be printed every time");
debug("this will only be printed if the DEBUG env var is set");

for more code examples check out the usage.rs example

§CLI Usage

WONT print the debug messages:

cargo r --example usage

WILL print the debug messages:

DEBUG=1 cargo r --example usage
Examples found in repository?
examples/usage.rs (line 9)
8fn main() {
9    debug("this will be printed only if the DEBUG environment variable is set");
10
11    let number = 123;
12    debug(&format!("{}", number));
13
14    let example_struct = Struct1 { string: String::from("string") };
15    debug(&format!("{:?}, field: {}", example_struct, example_struct.string));
16}