1 stable release
1.0.0 | May 23, 2019 |
---|
#38 in #everything
3KB
Debug-print everything!
If you - like me - frequently find yourself deep in a jungle of generic traits with
a sudden need to debug-print some data, this crate is for you.
The constant struggle of adding Debug
bounds everywhere only to remove
all of them (or at least the ones you can still find) as soon as you're done is over:
use debug_everything::Debuggable;
fn generic<T>(t: T) {
println!("t = {:?}", t.debug());
}
How it works
Sadly, this relies on specialization and thus only works on nightly (as of May 2019).
The Debuggable
trait is implemented for all types but specialized for types implementing
Debug
:
use debug_everything::Debuggable;
struct Dummy;
assert_eq!("42", format!("{:?}", 42.debug()));
assert_eq!("<no Debug impl>", format!("{:?}", Dummy.debug()));
Simple!