Puzzle 24Home on the Range
 fn​ ​main​() {
  .. .. ..;
 }

Guess the Output

images/aside-icons/important.png

Try to guess what the output is before moving to the next page.

images/hline.png

The program will compile and run, but it won’t display any output.

images/hline.png

Discussion

The .. symbol has a few meanings in Rust:

  • .. without numbers indicates a range containing every available value.

  • 1..3 creates a range that starts at 1 and stops at 2.

  • 1.. creates a range that starts at 1 and continues ...

Get Rust Brain Teasers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.