From 5ea1013067b856e96d75a5e39122b1b484f1ebf0 Mon Sep 17 00:00:00 2001 From: Rynco Maekawa Date: Thu, 11 Feb 2021 09:21:12 +0800 Subject: [PATCH] Docs and minor style change for `Arena::get2_mut` --- CHANGELOG.md | 1 + src/arena.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc8f7a..4135131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased Changes * Implemented `IntoIterator` for `&Arena` and `&mut Arena`. +* Added `Arena::get2_mut` for getting two mutable references of different slots at once. ## 0.4.0 (2020-11-17) * Added `Index::slot` for extracting the slot portion of an index. diff --git a/src/arena.rs b/src/arena.rs index 34dd686..e0252f0 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -221,9 +221,9 @@ impl Arena { } } - /// Get mutable references to two values inside this arena at once by - /// [`Index`], returning `None` if the corresponding index is not contained - /// in this arena. + /// Get mutable references of two values inside this arena at once by + /// [`Index`], returning `None` if the corresponding `index` is not + /// contained in this arena. /// /// # Panics /// @@ -234,7 +234,8 @@ impl Arena { panic!("Arena::get2_mut is called with two identical indices"); } - // Unsafe notes: + // SAFETY NOTES: + // // - If `index1` and `index2` have different slot number, `item1` and // `item2` would point to different elements. // - If `index1` and `index2` have the same slot number, only one could