let forty_twos = [42.0, 42f32, 42.0_f32];
println!("{:02}", forty_twos[0]);
I’m reading the book “Rust in Action”, and in the sample code I came across these two lines of code. Specifically, I have a question about the second one: what does “{:02}” do in println. If I replace it with {}, the output remains the same. This is probably stupid question but idk how to look for the answer in the documentation(there is no explanation in book).
I think it has something to do with formatting, but I can’t be sure of that
2
As said in the comments, this is used for printing leading zeros. See the documentation at https://doc.rust-lang.org/std/fmt.