Macro fastset::random

source ·
macro_rules! random {
    ($set:expr, $rng:expr) => { ... };
    ($set:expr) => { ... };
}
Expand description

Macro for selecting a random element from a Set.

If no random number generator is provided, it will use WyRand as the default.

§Example

let mut my_set = Set::new(10);
my_set.insert(1);
my_set.insert(2);

let random_elem = random!(my_set); // Use default RNG

let mut rng = WyRand::new();
let random_elem_custom_rng = random!(my_set, &mut rng); // Use custom RNG