Use the Debug Formatter
Rust's standard library types are all printable using the debug formatter {:?}
or the "pretty
printing" formatter {:#?}
.
fn main() { let vec = vec![0, 1, 2, 3]; println!("Debug: {:?}", vec); println!("Pretty print: {:#?}", vec); }
In contrast, the default formatter throws an error.
fn main() { let vec = vec![0, 1, 2, 3]; println!("{}", vec); }