From eea4d1cd134c65b4507996ed3b15ef7a82d797ef Mon Sep 17 00:00:00 2001 From: Nullptr Date: Fri, 26 Jul 2024 22:11:07 +0800 Subject: [PATCH] Make FrameAllocator::new const --- src/frame.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/frame.rs b/src/frame.rs index daf3f0f..8663c77 100644 --- a/src/frame.rs +++ b/src/frame.rs @@ -1,7 +1,6 @@ use super::prev_power_of_two; use alloc::collections::BTreeSet; use core::alloc::Layout; -use core::array; use core::cmp::{max, min}; use core::ops::Range; @@ -41,9 +40,9 @@ pub struct FrameAllocator { impl FrameAllocator { /// Create an empty frame allocator - pub fn new() -> Self { + pub const fn new() -> Self { Self { - free_list: array::from_fn(|_| BTreeSet::default()), + free_list: [const { BTreeSet::new() }; ORDER], allocated: 0, total: 0, }