What optimizations does the Rust compiler make with `loop` versus` while true?
1 answer
Other than what you state your intention, there is no difference. All loops are the same once the compiler has normalized.
See an example loop
on the Rust playground and the same example withwhile true
. The generated assembly is exactly the same. The compiler gives a warning for while true
-example to use loop
instead.
+1
source to share