Random Pick
Pick an element from a slice randomly by given weights.
Example
extern crate random_pick;
let prize_list = ; // available prizes
let slice = &prize_list;
let weights = ; // a scale of chance of picking each kind of prize
let n = 1000000;
let mut counter = ;
for _ in 0..n
println!; // Should be close to 20000
println!; // Should be close to 100000
println!; // Should be close to 300000
println!; // Should be close to 600000
The length of the slice is usually an integral multiple (larger than zero) of that of weights.
Crates.io
https://crates.io/crates/random-pick