Chooce video playback speed
speed:1

Create a loop in Rust

InstructorPascal Precht

Share this video with your friends

Send Tweet

This lesson shows how to use a Rust loop to run a program infinitely.

Instructor: To have our program keep asking the user for entering numbers, we can use a loop. Rust comes with several different types of loops. The simplest one is probably the loop loop. All we have to do is wrapping it around our code and closing it here.

If we now run the program again, it should continue asking us for numbers. As we can see, once we got the first results, it again asks us for first number and the second number. Now it just continues doing that forever.