pub fn get_random_item<'a, T, R>(
random: &mut R,
items: &'a [T],
weight: impl Fn(&T) -> i32,
) -> Option<&'a T>where
R: Random,Expand description
Picks an entry with probability proportional to its weight. A zero total
weight returns None without consuming random values.
ยงPanics
Panics if the total weight is negative.