debug_utils/
lib.rs

1// contents of rust_debug_utils/src/lib.rs
2use std::fmt;
3
4#[derive(Debug)]
5pub struct TypeOf<T>(pub T);
6
7impl<T: fmt::Debug> fmt::Display for TypeOf<T> {
8    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9        write!(f, " <{}> = {:#?}", std::any::type_name::<T>(), self.0)
10    }
11}
12
13#[macro_export]
14macro_rules! debug {
15    ($x:ident) => {
16        println!("{{{}}}{}", stringify!($x), $crate::TypeOf($x));
17    };
18}
19