In c++ I very often do this kind of looping:
for(float t=0; t < threshold; t += step_size)
{}
I am trying to replicate it in rust. I could of course use a while loop, but for loops with the above syntax have a couple of things I like:
- You can immediately tell how the loop should behave in one line (as opposed to 3)
- While loops force the update statement to be at the bottom, if your while is large that makes it harder to find the update statement if you need to tweak it.
- All metavariables associated with the loop exist only within the scope of the loop.
Can you replicate this in rust?