let v2 = vec![1; 10];
println!("{:?}", v2);
{}
is for strings and other values which can be displayed directly to the user. There's no single way to show a vector to a user.
The {:?}
formatter can be used to debug it, and it will look like:
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Display
is the trait that provides the method behind {}
, and Debug
is for {:?}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…