1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/// Similar to the `std::dbg!` macro, but inspects values by reference without
/// moving them. This allows debugging values without transferring ownership,
/// while showing the underlying value's type information (not reference types).
///
/// This macro uses [`log::debug!`] internally, so you must:
/// 1. Configure a logger (e.g., `env_logger`) with debug level enabled
/// 2. Initialize the logger before use
///
/// ## Key Differences from `std::dbg!`
///
/// - Returns `()` instead of the original value
/// - Requires explicit logger initialization
///
/// ## Examples
///
/// Basic usage
///
/// ```
/// use testutils::dbg_ref;
/// // Must initialize logger first:
/// // env_logger::builder().filter_level(log::LevelFilter::Debug).init();
///
/// let counter = 42;
/// dbg_ref!(counter); // [DEBUG] counter: i32 = 42
///
/// let message = "Hello";
/// dbg_ref!(message); // [DEBUG] message: &str = "Hello"
///
/// let values = vec![(1, "a"), (2, "b")];
/// dbg_ref!(values); // [DEBUG] values: alloc::vec::Vec<(i32, &str)> = [...]
/// ```
///
/// Debugging multiple values
///
/// ```
/// use testutils::dbg_ref;
/// let width = 30;
/// let label = "size";
///
/// dbg_ref!(width, label);
/// // Outputs:
/// // [DEBUG] width: i32 = 30
/// // [DEBUG] label: &str = "size"
/// ```
///
/// ## Implementation Notes
///
/// 1. Uses `core::any::type_name_of_val` for type information
/// 2. Formats output as: `{variable_name}: {type} = {debug_representation}`
/// 3. Multiple arguments generate separate log entries
// ===========================
/// Outputs the information of the expression(s) to stderr.
///
/// ```
/// use testutils::dbg;
/// let width = 30;
/// let label = "size";
///
/// dbg!(width, label);
/// // Outputs:
/// // width: i32 = 30
/// // label: &str = "size"
/// ```