This crate provides various guessing utilities for working with guesses in (0..101) number range. Check the documentation for more.
```rust use guessingutils; use guessingutils::Guess;
use std::io; use std::cmp::Ordering;
// fully working "guess the number" app! fn main() { println!("Guess the number!");
let secret_number = guessing_utils::gen_random();
loop {
println!("Please input your guess.");
let mut guess = String::new();
io::stdin()
.read_line(&mut guess)
.expect("Failed to read line");
let guess: Guess = match guessing_utils::Guess::parse(&guess) {
Ok(val) => val,
Err(_) => continue,
};
println!("You guessed: {}", guess.value());
match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small!"),
Ordering::Greater => println!("Too big!"),
Ordering::Equal => {
println!("You win!");
break;
}
}
}
} ```