Skip to main content
2 of 6
added 10 characters in body
ruohola
  • 664
  • 7
  • 15

When using string formatting for example with println!, one can use both numbered and unnumbered formatters to save some bytes.

Best shown with an example:

fn main() { println!("{} {} {0} {0} {1} {} {2}", "first", "second", "third"); } 

Will output:

first second first first second third third 

So the unnumbered formatters will get assigned to the values in order, this allows you to skip the index once per item.

ruohola
  • 664
  • 7
  • 15