Edit documentation.
This commit is contained in:
@@ -3,6 +3,11 @@ Infinite `loop`
|
||||
|
||||
{{#include ../links.md}}
|
||||
|
||||
Infinite loops follow C syntax.
|
||||
|
||||
Like C, `continue` can be used to skip to the next iteration, by-passing all following statements;
|
||||
`break` can be used to break out of the loop unconditionally.
|
||||
|
||||
```rust
|
||||
let x = 10;
|
||||
|
||||
@@ -13,3 +18,6 @@ loop {
|
||||
if x == 0 { break; } // break out of loop
|
||||
}
|
||||
```
|
||||
|
||||
Beware: a `loop` statement without a `break` statement inside its loop block is infinite -
|
||||
there is no way for the loop to stop iterating.
|
||||
|
Reference in New Issue
Block a user