The Rust tutorial, and now book claim there is a difference between while true and loop, but that it isn\'t super important to understand at this stage
while true
loop
One major difference is that loop can return a value by passing a value to break. while and for will not:
break
while
for
fn main() { let mut counter = 0; let result = loop { counter += 1; if counter == 10 { break counter * 2; } }; assert_eq!(result, 20); }