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 ?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With