[Rust Guide] 2.4. Number Guessing Game Pt.4 - Repeated Prompting with Loop
2.4.0. Key Points of This Section This is the final part of the number guessing game. The key points in this section are: loop break continue Flexible use of match How to handle enum types 2.4.1. G...
![[Rust Guide] 2.4. Number Guessing Game Pt.4 - Repeated Prompting with Loop](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%2Fh78zddiiy9fhfmyiqdxr.png)
Source: DEV Community
2.4.0. Key Points of This Section This is the final part of the number guessing game. The key points in this section are: loop break continue Flexible use of match How to handle enum types 2.4.1. Game Objectives Generate a random number between 1 and 100 Prompt the player to enter a guess After the guess, the program will tell whether the guess is too big or too small Keep asking repeatedly. If the guess is correct, print a congratulatory message and exit the program (covered in this section) 2.4.2. Code Implementation Step 1: Implementing a Loop In the previous code, we implemented the comparison for one input. Next, we need to implement repeated prompts and repeated comparisons until the user guesses the correct number. Here is the code up to the section before this one: use std::io; use rand::Rng; use std::cmp::Ordering; fn main() { let range_number = rand::thread_rng().gen_range(1..101); println!("Number Guessing Game"); println!("Guess a number"); let mut guess = String::new(); io