0

I am trying to print a Vec with variables of other datatypes:

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);

but I get this error:

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`

How do I print the Vec at a particular position in the output string?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Abhijay Ghildyal
  • 4,044
  • 6
  • 33
  • 54

0 Answers0