1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use permutations::Permutation;
use rand::thread_rng;
pub trait Shuffle {
fn permutation(self, len: usize) -> Permutation;
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Random;
impl Shuffle for Random {
fn permutation(self, len: usize) -> Permutation {
Permutation::random(&mut thread_rng(), len)
}
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct Noop;
impl Shuffle for Noop {
fn permutation(self, len: usize) -> Permutation {
Permutation::identity(len)
}
}