#030
Mar 19, 2026
30. dbg! macro
Still using println! for quick debugging? Try dbg! instead — it prints the expression, its value, and the file/line number to stderr. And it returns the value, so you can wrap it around anything.
| |
Unlike println!, dbg! takes ownership (or copies for Copy types). If you need to keep the value, pass a reference:
| |
Bonus: dbg! works the same in release builds, and outputs to stderr so it won’t pollute your stdout.