Start with the idea
println! takes a format string and turns values into a line on stdout. In the example, {name} and {builds} capture bindings with those names. The macro checks the placeholders while compiling, so a misspelled capture or missing positional argument becomes a diagnostic before the program runs. This is safer than assembling a message with a chain of ad hoc string additions, especially when the output becomes a log line or a table someone else must read.
Formatting controls presentation without changing the stored value. In {builds:>3}, the colon introduces a format specification: > right-aligns the value in a field three characters wide. With builds = 4, that line begins with two spaces and then 4. Predict the whitespace rather than relying on how a proportional font looks. Try replacing a named capture with {} and pass the value explicitly; then remove the argument and observe how rustc identifies the mismatch.
Keep learning, for free
The rest of this lesson is waiting for you.
Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.
No payment details. Your account opens the complete Academy.