April 2026
Intermediate
631 pages
16h 20m
English
Control flow (or the flow of control) refers to the order in which individual statements, instructions are executed or evaluated in a program. In this section, we’ll go over the fundamental control flow construct called a loop and its different types. You’ll use loops to handle repetitive tasks efficiently.
The first type of loop is simply a loop. The code after this loop construct executes forever. For instance, the following code will execute infinitely:
loop { println!("Simple loop");}
This code will print Simple loop forever. To exit out of a loop, you can use a break statement, as in the following example:
loop { println!("Simple loop"); break;}
If you have nested loops (i.e., a loop containing ...
Read now
Unlock full access