Back to questions
JuniorTheoryOccasional
What happens when this program is built and run?
fn main() {
let x = 5;
println!("{} {}", x);
}It does not compile
- Expecting a panic at run time:
println!checks the format string while compiling, so the missing argument stops the build and nothing runs. - Expecting
xto fill both placeholders: each{}takes its own argument, so two{}need two arguments.
- How would you fix the line so that it prints
5 5? - What does the compiler say when there are more arguments than placeholders?