"rust guessing game" Code Answer's
You're definitely familiar with the best coding language Rust that developers use to develop their projects and they get all their queries like "rust guessing game" answered properly. Developers are finding an appropriate answer about rust guessing game related to the Rust coding language. By visiting this online portal developers get answers concerning Rust codes question like rust guessing game. Enter your desired code related query in the search bar and get every piece of information about Rust code related question on rust guessing game.
rust guessing game

//Guessing Game from Rust Book
use std::io;
use rand::Rng;
use std::cmp::Ordering;
fn main() {
let secret:i32 = rand::thread_rng().gen_range(1, 101);
loop{
println!("Ingresa un número: ");
let mut guess = String::new();
io::stdin().read_line(&mut guess).expect("Failed to read line");
let guess:i32 = match guess.trim().parse(){
Ok(num) => num,
Err(_) => continue,
};
//print!("tu numero {}", guess);
match guess.cmp(&secret){
Ordering::Less => println!("Más arriba!"),
Ordering::Greater => println!("Más abajo!"),
Ordering::Equal => {
println!("Ese mismo compadre");
break;
}
}
}
}
All those coders who are working on the Rust based application and are stuck on rust guessing game can get a collection of related answers to their query. Programmers need to enter their query on rust guessing game related to Rust code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about rust guessing game for the programmers working on Rust code while coding their module. Coders are also allowed to rectify already present answers of rust guessing game while working on the Rust language code. Developers can add up suggestions if they deem fit any other answer relating to "rust guessing game". Visit this developer's friendly online web community, CodeProZone, and get your queries like rust guessing game resolved professionally and stay updated to the latest Rust updates.