What Is the dbg! Macro and How to Use It for Debugging?

The dbg! macro prints an expression's value and location to stderr, then returns the value unchanged for inline debugging.

The dbg! macro prints the file, line, and value of an expression, then returns that value unchanged so you can debug without rewriting code. Wrap any expression or variable in dbg!() to inspect it at runtime.

use std::env;

fn main() {
    let args: Vec<String> = env::args().collect();
    dbg!(args);
}