Function sample_single_from_known_length

Source
pub fn sample_single_from_known_length<'a, Container, R, T>(
    rng: &mut R,
    set: &'a Container,
) -> Option<T>
where R: Rng, Container: HasLen + HasIter<Item<'a> = &'a T>, T: Clone + 'static,
Expand description

Sample a random element uniformly from a container of known length.

We do not assume the container is randomly indexable, only that it can be iterated over. The value is cloned. This algorithm is used when the property is indexed, and thus we know the length of the result set.