rusty_perm/rand.rs
1#![cfg(feature = "rand")]
2
3use crate::perm_type::PermS;
4use rand::{
5 distributions::{Distribution, Standard},
6 prelude::*,
7};
8
9impl<const SIZE: usize> Distribution<PermS<SIZE>> for Standard {
10 /// Sample an random static permutation.
11 fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> PermS<SIZE> {
12 let mut perm = PermS::<SIZE>::identity();
13 perm.indices.shuffle(rng);
14 perm
15 }
16}