Macro custom_print::define_dbg
source · macro_rules! define_dbg { ( $( #[$meta:meta] )* $name:ident, $($args:tt)* ) => { ... }; }
Expand description
Defines dbg
macro that prints and returns the value
of a given expression for quick and dirty debugging.
The implementation of the generated dbg
-like macro
is based on std::dbg
macro implementation,
but the exact output printed by std::dbg
should not be relied upon and is subject to future changes.
The first argument specifies the generated macro name.
The writer itself is specified by the rest arguments with the define_writer
macros.
Use define_try_dbg
if you need to define a fallible dbg macros.
Examples
let mut string = String::new();
custom_print::define_dbg!(cdbg, concat, |value: &str| string += value);
assert_eq!(cdbg!("value"), "value");
assert!(string.contains("\"value\""));