In this tutorial you will learn about the Rust Loop and its application with practical example.
Rust Loop
This loop statement is the simplest form of loop available in Rust. The loop statement provides a way to loop through indefinitely until some terminating statement is found.
Syntax:-
1 2 3 |
loop { // Statements(s) } |
Example :-
1 2 3 |
loop { println!("W3Adda Loop forever!"); } |
The “break” keyword is used to terminate the loop, if there is no “break” keyword is used then the loop will be executed indefinitely.