[][src]Macro drone_core::dbg

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

Prints and returns the value of a given expression for quick and dirty debugging.

The macro works by using the Debug implementation of the type of the given expression to print the value to the log port #1 along with the source location of the macro invocation as well as the source code of the expression.

Invoking the macro on an expression moves and takes ownership of it before returning the evaluated expression unchanged. If the type of the expression does not implement Copy and you don't want to give up ownership, you can instead borrow with dbg!(&expr) for some expression expr.

Examples

let a = 2;
let b = dbg!(a * 2) + 1;
//      ^-- prints: [src/main.rs:2] a * 2 = 4
assert_eq!(b, 5);