Skip to content

Commit

Permalink
Mention required #![feature(const_fn)] attribute again for FixedSiz…
Browse files Browse the repository at this point in the history
…eBlockAllocator

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 #720 (comment).
  • Loading branch information
phil-opp committed Aug 19, 2020
1 parent 9b61e06 commit 10d84fa
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 10d84fa

Please sign in to comment.