use array map in timer constructor
authoralfadur
Thu, 09 Sep 2021 21:06:45 +0300
changeset 15840 0c21cdbc5207
parent 15839 0defc1d3261d
child 15841 c5198f55ee1c
use array map in timer constructor
rust/hedgewars-server/src/core/events.rs
--- a/rust/hedgewars-server/src/core/events.rs	Tue Sep 07 01:45:16 2021 +0300
+++ b/rust/hedgewars-server/src/core/events.rs	Thu Sep 09 21:06:45 2021 +0300
@@ -29,12 +29,7 @@
 impl<Data, const MAX_TIMEOUT: usize> TimedEvents<Data, MAX_TIMEOUT> {
     pub fn new() -> Self {
         Self {
-            events: iter::repeat_with(|| Slab::new())
-                .take(MAX_TIMEOUT)
-                .collect::<Vec<_>>()
-                .try_into()
-                .ok()
-                .unwrap(),
+            events: [0; MAX_TIMEOUT].map(|_| Slab::new()),
             current_time: Instant::now(),
             current_tick_index: 0,
             next_event_id: 0,