deliberate.codes

Practical AI for data & software engineers. What works, no hype.

Rust's dbg! macro preserves expression value

The dbg! macro in Rust not only prints debug output but also returns the value, making it perfect for inline debugging:

let result = dbg!(expensive_calculation());

This prints [src/main.rs:1] expensive_calculation() = 42 and assigns 42 to result. No need to split into separate lines for debugging.