Skip to content

Commit bce9780

Browse files
authored
time: use array::from_fn instead of manually creating array (#7000)
1 parent 38151f3 commit bce9780

File tree

1 file changed

+1
-77
lines changed

1 file changed

+1
-77
lines changed

tokio-util/src/time/wheel/level.rs

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -39,86 +39,10 @@ const LEVEL_MULT: usize = 64;
3939

4040
impl<T: Stack> Level<T> {
4141
pub(crate) fn new(level: usize) -> Level<T> {
42-
// Rust's derived implementations for arrays require that the value
43-
// contained by the array be `Copy`. So, here we have to manually
44-
// initialize every single slot.
45-
macro_rules! s {
46-
() => {
47-
T::default()
48-
};
49-
}
50-
5142
Level {
5243
level,
5344
occupied: 0,
54-
slot: [
55-
// It does not look like the necessary traits are
56-
// derived for [T; 64].
57-
s!(),
58-
s!(),
59-
s!(),
60-
s!(),
61-
s!(),
62-
s!(),
63-
s!(),
64-
s!(),
65-
s!(),
66-
s!(),
67-
s!(),
68-
s!(),
69-
s!(),
70-
s!(),
71-
s!(),
72-
s!(),
73-
s!(),
74-
s!(),
75-
s!(),
76-
s!(),
77-
s!(),
78-
s!(),
79-
s!(),
80-
s!(),
81-
s!(),
82-
s!(),
83-
s!(),
84-
s!(),
85-
s!(),
86-
s!(),
87-
s!(),
88-
s!(),
89-
s!(),
90-
s!(),
91-
s!(),
92-
s!(),
93-
s!(),
94-
s!(),
95-
s!(),
96-
s!(),
97-
s!(),
98-
s!(),
99-
s!(),
100-
s!(),
101-
s!(),
102-
s!(),
103-
s!(),
104-
s!(),
105-
s!(),
106-
s!(),
107-
s!(),
108-
s!(),
109-
s!(),
110-
s!(),
111-
s!(),
112-
s!(),
113-
s!(),
114-
s!(),
115-
s!(),
116-
s!(),
117-
s!(),
118-
s!(),
119-
s!(),
120-
s!(),
121-
],
45+
slot: std::array::from_fn(|_| T::default()),
12246
}
12347
}
12448

0 commit comments

Comments
 (0)