Rust TutorialLesson 15Free preview
Rust While Loops
This lesson is part of Rust · All levels
Summary
This lesson reviews conditional repetition using the keyword 'while' in Rust. The code within the while block will be executed repeatedly during the value of the condition. Once the condition is evaluated to false, the repetition will be completed and the program continues the next instruction.
Key points
- The 'while' iteration evaluates the condition before each iteration
- It's perfectly suited for use when the number of iterations cannot be determined at the beginning.
- Reduces the risk of endless repetitive errors compared to manual loops
- It can be combined with the keywords 'break' and 'continue'
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.