]> git.nega.tv - josh/narcissus/commitdiff
Switch thread token to `std::array::from_fn`
authorJoshua Simmons <josh@nega.tv>
Thu, 8 Sep 2022 16:55:24 +0000 (18:55 +0200)
committerJoshua Simmons <josh@nega.tv>
Thu, 8 Sep 2022 16:55:24 +0000 (18:55 +0200)
narcissus-core/src/lib.rs

index 180c7574e3750a61f8ca56760cc51a48f4a8cf0b..3c506055620731deec94e1973fca7e6c1b11896a 100644 (file)
@@ -73,12 +73,8 @@ macro_rules! thread_token_def {
                 where
                     F: FnMut() -> T,
                 {
-                    let mut slots = uninit_array();
-                    for elem in &mut slots[..] {
-                        elem.write(UnsafeCell::new(f()));
-                    }
                     Self {
-                        slots: unsafe { array_assume_init(slots) },
+                        slots: std::array::from_fn(|_| UnsafeCell::new(f())),
                     }
                 }