Reputation: 363
Aside from the fact that it can reason about uninitialized values set within the loop
body, are there any other compelling reasons for loop
to exist ?
Upvotes: 4
Views: 467
Reputation: 16475
Other than you state your intention, there is no difference. All loops are the same once normalization has happened in the compiler.
See an example of a loop
in the Rust playground and the same example with a while true
. The assembly generated is exactly the same. The compiler gives a warning for the while true
-example to use loop
instead.
Upvotes: 1