我正在尝试使用其他数据类型的变量打印Vec
:
let a = 4;
let b = vec![1,2,3,4];
let c = 3;
// printing input
println!("a: {0}, b: {1}, c: {2}", a, b, c);
但是我收到了这个错误:
error[E0277]: the trait bound `std::vec::Vec<{integer}>: std::fmt::Display` is not satisfied
--> src/main.rs:23:43
|
23 | println!("a: {0}, b: {1}, c: {2}", a, b, c);
| ^ trait `std::vec::Vec<{integer}>: std::fmt::Display` not satisfied
|
= note: `std::vec::Vec<{integer}>` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
= note: required by `std::fmt::Display::fmt`
如何在输出字符串中的特定位置打印Vec
?