Stage 7.13: Formatting Strings
The format!
macro allows us to create a string by defining a parameterized string
with placeholders for where and how values should be placed, e. g. {}
).
format!
uses the same parameterized strings as println!
To print arrays, structs, enums etc. you simple add :?
to the curly brackets, e. g.
{:?}
You can also use a pretty-print by adding :#?
to the curly brackets, e. g.
{:#?}
Further information: