google / comprehensive-rust

This is the Rust course used by the Android team at Google. It provides you the material to quickly teach Rust.

Home Page:https://google.github.io/comprehensive-rust/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

concurrency: Avoid `1..ROUND_NUMBER` loops

fw-immunant opened this issue · comments

Teaching the concurrency course it sticks out as strange that many of the example loops start at 1 and continue to (exclusively) a round number, such as 1..5 or 1..10. This means we're comparing, for example, a loop in main that counts 1 2 3 4 with a loop in a background thread that counts 1 2 3 4 5 6 7 8 9: 4 and 9 iterations, respectively. I think it would be less distracting to loop for round numbers of iterations like 5 or 10, whether we start at 1 or 0. When I see a loop that starts 1 and has a non-inclusive end bound, my bug sense tingles, and I figure the same is probably true for a number of students; it's less distracting to do something more idiomatic as looping is not the focus here.

Sounds like a good fix!