From 8593b48902949b2efe1cd54c5074831fdd8d9fc6 Mon Sep 17 00:00:00 2001 From: bendn Date: Thu, 15 Feb 2024 09:04:51 +0700 Subject: [PATCH] cleaner initialization of `PermutationTable` --- README.md | 4 ++-- src/permutationtable.rs | 8 +------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 285da982..38bbfe51 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,6 @@ Project Link: [https://github.com/razaekel/noise-rs][github link] [planet surface 16x]: /images/unscaledFinalPlanet_16x_zoom.png -[rust version badge]: https://img.shields.io/badge/rust-1.60.0+-93450a.svg?style=for-the-badge&logo=rust +[rust version badge]: https://img.shields.io/badge/rust-1.63.0+-93450a.svg?style=for-the-badge&logo=rust -[rust version link]: https://blog.rust-lang.org/2022/04/07/Rust-1.60.0.html +[rust version link]: https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html diff --git a/src/permutationtable.rs b/src/permutationtable.rs index 282891e9..00aa8d8c 100644 --- a/src/permutationtable.rs +++ b/src/permutationtable.rs @@ -25,14 +25,8 @@ impl Distribution for Standard { /// Generates a PermutationTable using a random seed. fn sample(&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