Skip to content

Commit 69a498c

Browse files
committed
The const_mut_refs feature is stable now and no longer required
1 parent 4de9527 commit 69a498c

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

blog/content/edition-2/posts/11-allocator-designs/index.ja.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ impl ListNode {
511511
}
512512
```
513513

514-
この型は`new`という単純なコンストラクタ関数を持ち、表現する領域の開始・終端アドレスを計算するメソッドを持っています。`new`関数は[const関数][const function]としていますが、これは後で静的な連結リストアロケータを作る際に必要になるためです。const関数においては、あらゆる可変参照の使用(`next`フィールドを`None`にすることも含め)はunstableであることに注意してください。コンパイルを通すためには、`#![feature(const_mut_refs)]``lib.rs`の最初に追加する必要があります。
514+
この型は`new`という単純なコンストラクタ関数を持ち、表現する領域の開始・終端アドレスを計算するメソッドを持っています。`new`関数は[const関数][const function]としていますが、これは後で静的な連結リストアロケータを作る際に必要になるためです。
515515

516516
[const function]: https://doc.rust-lang.org/reference/items/functions.html#const-functions
517517

@@ -968,8 +968,6 @@ impl FixedSizeBlockAllocator {
968968

969969
[`empty`]: https://docs.rs/linked_list_allocator/0.9.0/linked_list_allocator/struct.Heap.html#method.empty
970970

971-
もし`LinkedListAllocator`を実装するときにまだやっていないのなら、 **`#![feature(const_mut_refs)]`**`lib.rs`の最初に追記しないといけません。const関数内におけるあらゆる可変参照型の使用はまだunstableで、それには`list_heads`フィールドの配列要素の型である`Option<&'static mut ListNode>`も(その値を`None`にしているにもかかわらず)含まれるからです。
972-
973971
このunsafeな`init`関数は`fallback_allocator`[`init`]関数を呼ぶだけで、`list_heads`配列の初期化などは行いません。これらの配列の初期化は、`alloc``dealloc`呼び出しが行われたときに初めて行います。
974972

975973
[`init`]: https://docs.rs/linked_list_allocator/0.9.0/linked_list_allocator/struct.Heap.html#method.init

blog/content/edition-2/posts/11-allocator-designs/index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl ListNode {
510510
}
511511
```
512512

513-
The type has a simple constructor function named `new` and methods to calculate the start and end addresses of the represented region. We make the `new` function a [const function], which will be required later when constructing a static linked list allocator. Note that any use of mutable references in const functions (including setting the `next` field to `None`) is still unstable. In order to get it to compile, we need to add **`#![feature(const_mut_refs)]`** to the beginning of our `lib.rs`.
513+
The type has a simple constructor function named `new` and methods to calculate the start and end addresses of the represented region. We make the `new` function a [const function], which will be required later when constructing a static linked list allocator.
514514

515515
[const function]: https://doc.rust-lang.org/reference/items/functions.html#const-functions
516516

@@ -967,8 +967,6 @@ The `new` function just initializes the `list_heads` array with empty nodes and
967967

968968
[`empty`]: https://docs.rs/linked_list_allocator/0.9.0/linked_list_allocator/struct.Heap.html#method.empty
969969

970-
If you haven't done so already for the `LinkedListAllocator` implementation, you also need to add **`#![feature(const_mut_refs)]`** to the top 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`).
971-
972970
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.
973971

974972
[`init`]: https://docs.rs/linked_list_allocator/0.9.0/linked_list_allocator/struct.Heap.html#method.init

0 commit comments

Comments
 (0)