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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
//! Procedural macros for the `lupa` inspector.
//!
//! This crate provides three macros that are re‑exported by the main `lupa`
//! crate. They are the primary interface for capturing snapshots and
//! computing diffs.
//!
//! - [`inspect!`] – captures a snapshot and sends it to the inspector.
//! - [`snapshot!`] – returns a `Snapshot` value for later diffing.
//! - [`snapshot_diff!`] – compares two snapshots and sends the diff.
//!
//! All macros capture the source location (`file!()`, `line!()`) and the
//! stringified expression automatically.
use TokenStream;
use quote;
use ;
/// Captures a snapshot of any value that implements `Debug` and sends it
/// to the lupa inspector (web UI and/or TUI).
///
/// The macro evaluates the expression, takes its `{:#?}` debug representation,
/// and records it along with the source location and the expression itself as
/// a label. The snapshot becomes visible in the inspector's "Snapshots" tab.
///
/// # Return value
/// The macro returns the original value (by reference) so it can be used
/// inline, similar to `dbg!`.
///
/// # Example
/// ```rust,ignore
/// let user = User::new("Alice");
/// inspect!(user); // snapshot appears in lupa
/// ```
///
/// # Feature flags
/// When the `web` feature is enabled (default), the snapshot is also broadcast
/// over WebSocket to all connected browser clients.
/// Creates a named snapshot without immediately sending it to the inspector.
///
/// Unlike `inspect!`, this macro returns a `Snapshot` struct that can be
/// stored and later used with `snapshot_diff!`. This is useful for capturing
/// a "before" state that you want to compare with an "after" state.
///
/// # Return value
/// Returns a `lupa::Snapshot` value.
///
/// # Example
/// ```rust,ignore
/// let s1 = snapshot!(user);
/// user.change_something();
/// snapshot_diff!(s1, user);
/// ```
/// Computes a diff between two snapshots and sends the result to the inspector.
///
/// The first argument must be a `Snapshot` (typically created earlier with
/// `snapshot!`). The second argument is any value that implements `Debug`;
/// it is immediately turned into a new snapshot. The macro computes a
/// line‑by‑line diff between the two debug representations and sends the
/// result to the inspector, where it appears in the "Diffs" tab.
///
/// # Example
/// ```rust,ignore
/// let before = snapshot!(user);
/// user.name = "Bob".into();
/// snapshot_diff!(before, user);
/// ```
///
/// # Note
/// The macro does not return a value. It only sends the diff to the inspector.