[Rust Guide] 3.6. Control Flow - Loops
3.6.0. Before the Main Content Welcome to Chapter 3 of Rust self-study. There are 6 sections in total: Variables and Mutability Data Types: Scalar Types Data Types: Compound Types Functions and Com...
![[Rust Guide] 3.6. Control Flow - Loops](https://media2.dev.to/dynamic/image/width=1200,height=627,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg80vrpkfo2sx9by40kcv.png)
Source: DEV Community
3.6.0. Before the Main Content Welcome to Chapter 3 of Rust self-study. There are 6 sections in total: Variables and Mutability Data Types: Scalar Types Data Types: Compound Types Functions and Comments Control Flow: if else Control Flow: Loops (this article) Through the small game in Chapter 2 (strongly recommended for beginners who haven't read it), you should already understand the basic syntax of Rust. In Chapter 3, we will go deeper and learn general programming concepts in Rust. If you like it, remember to like, bookmark, and follow. Follow the series if you want to keep learning. 3.6.1. Loops in Rust Rust provides three types of loops: loop while for 3.6.2. loop Loop The loop keyword tells Rust to repeatedly execute a block of code until explicitly stopped. fn main(){ loop { println!("6657 up up!"); } } You can use the break keyword to stop a loop: fn main(){ let mut counter = 0; let result = loop { counter += 1; if counter == 10 { break counter * 2; } }; println!("The result is