Function rand::sample [] [src]

pub fn sample<T, I: Iterator<Item=T>, R: Rng>(rng: &mut R, iter: I, amount: usize) -> Vec<T>

Randomly sample up to amount elements from an iterator.

Example

use rand::{thread_rng, sample};

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