Function rand04::sample

source ·
pub fn sample<T, I, R>(rng: &mut R, iterable: I, amount: usize) -> Vec<T, Global>where
    I: IntoIterator<Item = T>,
    R: Rng,
👎Deprecated since 0.4.0: renamed to seq::sample_iter
Expand description

DEPRECATED: use seq::sample_iter instead.

Randomly sample up to amount elements from a finite iterator. The order of elements in the sample is not random.

Example

use rand::{thread_rng, sample};

let mut rng = thread_rng();
let sample = sample(&mut rng, 1..100, 5);
println!("{:?}", sample);