mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 22:37:49 +00:00
Mention required #![feature(const_fn)] attribute again for FixedSizeBlockAllocator
The post explicitly allows readers to skip the `LinkedListAllocator` implementation, so we should not rely that the reader already enabled the unstable `const_fn` function there. Reported in https://github.com/phil-opp/blog_os/issues/720#issuecomment-672625377.
This commit is contained in:
@@ -969,6 +969,8 @@ The `new` function just initializes the `list_heads` array with empty nodes and
|
||||
|
||||
[`empty`]: https://docs.rs/linked_list_allocator/0.6.4/linked_list_allocator/struct.Heap.html#method.empty
|
||||
|
||||
If you haven't done so already for the `LinkedListAllocator` implementation, you also need to add **`#![feature(const_fn)]`** to the beginning of your `lib.rs`. The reason is that any use of mutable reference types in const functions is still unstable, including the `Option<&'static mut ListNode>` array element type of the `list_heads` field (even if we set it to `None`).
|
||||
|
||||
The unsafe `init` function only calls the [`init`] function of the `fallback_allocator` without doing any additional initialization of the `list_heads` array. Instead, we will initialize the lists lazily on `alloc` and `dealloc` calls.
|
||||
|
||||
[`init`]: https://docs.rs/linked_list_allocator/0.6.4/linked_list_allocator/struct.Heap.html#method.init
|
||||
|
||||
Reference in New Issue
Block a user