Skip to content

Commit 95e5d6c

Browse files
authored
Merge pull request #34 from Dr-TSNG/master
Make FrameAllocator::new const
2 parents 52eac27 + eea4d1c commit 95e5d6c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/frame.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::prev_power_of_two;
22
use alloc::collections::BTreeSet;
33
use core::alloc::Layout;
4-
use core::array;
54
use core::cmp::{max, min};
65
use core::ops::Range;
76

@@ -41,9 +40,9 @@ pub struct FrameAllocator<const ORDER: usize = 32> {
4140

4241
impl<const ORDER: usize> FrameAllocator<ORDER> {
4342
/// Create an empty frame allocator
44-
pub fn new() -> Self {
43+
pub const fn new() -> Self {
4544
Self {
46-
free_list: array::from_fn(|_| BTreeSet::default()),
45+
free_list: [const { BTreeSet::new() }; ORDER],
4746
allocated: 0,
4847
total: 0,
4948
}

0 commit comments

Comments
 (0)