[英]What optimizations does the Rust compiler make with `loop` versus `while true`?
除了可以推断loop
体内设置的未初始化值这一事实之外,还有其他令人信服的理由存在loop
吗?
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
. 请参阅Rust操场中的
loop
示例以及while true
的相同示例 。 The assembly generated is exactly the same. 生成的组件完全相同。 The compiler gives a warning for the
while true
-example to use loop
instead. 编译器为
while true
-example提供警告,以便使用loop
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.