Consider this example program—the Test struct is decorated with the derive Debug syntax. It is important to start the line with the "#" symbol.
#[derive(Debug)]
struct Test {
code: usize,
values: Vec<u8>,
}
fn main() {
// Step 1: Create new struct.
let test = Test {
code: 10,
values: vec![10, 20, 30],
};
// Step 2: Use debug formatting.
println!(
"{:?}", test);
// Step 3: Use pretty-print debug formatting.
println!(
"{:#?}", test);
}
Test { code: 10, values: [10, 20, 30] }
Test {
code: 10,
values: [
10,
20,
30,
],
}