Skip to content
masterclass Buddy

Rust · Macro

dbg!

Rust’s dbg! macro prints an expression’s location, source text, and Debug value to stderr, then returns the value. It is for quick debugging and also works in release builds.

Last updated

Since
1.32.0

Syntax

macro_rules! dbg { () => { ... }; ($val:expr $(,)?) => { ... }; ($($val:expr),+ $(,)?) => { ... }; }

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • Debug
  • stderr
  • debug!
  • log

Source: dbg in std - Rust. Checked 2026-11-03.