The format! Macro
We’ve used the println!
and print!
macros previously to generate and print output. There’s another macro that goes along with them, the format!
macro. It works in almost exactly the same way, but instead of printing the output, it generates a String
value. For example: