Skip to content
Snippets Groups Projects
Verified Commit a5536cdc authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

Revert "use shuffle again..."

This reverts commit c2b6f4db.
parent c2b6f4db
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !127. Comments created here will be created in the context of that merge request.
use rand::{seq::SliceRandom, Rng, RngCore};
use rand::{Rng, RngCore};
use std::collections::HashSet;
#[allow(dead_code)]
fn draw_unique_indices(n: usize, vec_len: usize, rng: &mut impl RngCore) -> HashSet<usize> {
let mut indices = HashSet::new();
......@@ -18,8 +17,9 @@ pub(super) fn draw_unique_elements<T: Clone>(
n: usize,
rng: &mut impl RngCore,
) -> Vec<T> {
let mut things = things.to_vec();
things.shuffle(rng);
things.iter().take(n).cloned().collect()
let mut res = vec![];
for i in draw_unique_indices(n, things.len(), rng) {
res.push(things[i].clone());
}
res
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment