Macro dbc::formatvar [] [src]

macro_rules! formatvar {
    ($var:ident) => { ... };
    ($var:ident, $($arg:tt)*) => { ... };
}

Stringify one or more variables and their values

This macro is used by other macros in rust-dbc to output the variables requested and their values. Structs can be displayed only if they have the [#derive(Debug)] attribute.

Examples


#[derive(Debug)]
struct AA(i32);

#[derive(Debug)]
struct BB(AA);

let a = 34;
let b = BB(AA(234));
let msg = "My message";

// Output: a=34
println!("{}", formatvar!(a));

// Output: b=BB(AA(234))
println!("{}", formatvar!(b));

// Output: msg="My message" a=34 b=BB(AA(234))
println!("{}", formatvar!(msg,a,b));