Generate a random u8 from 0 to 255 inclusively
Use the gen
method instead. This method will generate a random value from the whole set of possible values for the specified type.
extern crate rand;
use rand::Rng;
fn main() {
println!("Guess the number!");
let random_number: u8 = rand::thread_rng().gen();
println!("Your random number is {}", random_number);
}