Skip to content

Commit

Permalink
cleaner initialization of PermutationTable
Browse files Browse the repository at this point in the history
  • Loading branch information
bend-n authored and Razaekel committed May 19, 2024
1 parent fec36c8 commit 84ee338
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/permutationtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ impl Distribution<PermutationTable> for Standard {
/// Generates a PermutationTable using a random seed.
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> PermutationTable {
let mut perm_table = PermutationTable {
values: [0; TABLE_SIZE],
values: core::array::from_fn(|x| x as u8),
};

perm_table
.values
.iter_mut()
.enumerate()
.for_each(|(i, b)| *b = i as u8);
perm_table.values.shuffle(rng);

perm_table
Expand Down

0 comments on commit 84ee338

Please sign in to comment.