about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorStein Somers <git@steinsomers.be>2022-05-22 13:46:54 +0200
committerStein Somers <git@steinsomers.be>2022-06-08 12:22:18 +0200
commit6f92f5ab66aa5e732e724ec24d825558f326e28f (patch)
tree69c1a855e7eb75e583b78bf42039dcfb5f107e21 /library/alloc
parent64a7aa7016de32f4d991c30bfa40d3911e18a213 (diff)
downloadrust-6f92f5ab66aa5e732e724ec24d825558f326e28f.tar.gz
rust-6f92f5ab66aa5e732e724ec24d825558f326e28f.zip
BTree: tweak internal comments
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/collections/btree/fix.rs4
-rw-r--r--library/alloc/src/collections/btree/map/entry.rs9
2 files changed, 7 insertions, 6 deletions
diff --git a/library/alloc/src/collections/btree/fix.rs b/library/alloc/src/collections/btree/fix.rs
index c4861817dd0..fd73fde2acb 100644
--- a/library/alloc/src/collections/btree/fix.rs
+++ b/library/alloc/src/collections/btree/fix.rs
@@ -91,8 +91,8 @@ impl<K, V> Root<K, V> {
         }
     }
 
-    /// Stock up any underfull nodes on the right border of the tree.
-    /// The other nodes, those that are not the root nor a rightmost edge,
+    /// Stocks up any underfull nodes on the right border of the tree.
+    /// The other nodes, those that are neither the root nor a rightmost edge,
     /// must be prepared to have up to MIN_LEN elements stolen.
     pub fn fix_right_border_of_plentiful(&mut self) {
         let mut cur_node = self.borrow_mut();
diff --git a/library/alloc/src/collections/btree/map/entry.rs b/library/alloc/src/collections/btree/map/entry.rs
index cacd06b5df1..e2749aac694 100644
--- a/library/alloc/src/collections/btree/map/entry.rs
+++ b/library/alloc/src/collections/btree/map/entry.rs
@@ -315,7 +315,7 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
     pub fn insert(self, value: V) -> &'a mut V {
         let out_ptr = match self.handle {
             None => {
-                // SAFETY: We have consumed self.handle and the reference returned.
+                // SAFETY: There is no tree yet so no reference to it exists.
                 let map = unsafe { self.dormant_map.awaken() };
                 let mut root = NodeRef::new_leaf();
                 let val_ptr = root.borrow_mut().push(self.key, value) as *mut V;
@@ -325,16 +325,17 @@ impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
             }
             Some(handle) => match handle.insert_recursing(self.key, value) {
                 (None, val_ptr) => {
-                    // SAFETY: We have consumed self.handle and the handle returned.
+                    // SAFETY: We have consumed self.handle.
                     let map = unsafe { self.dormant_map.awaken() };
                     map.length += 1;
                     val_ptr
                 }
                 (Some(ins), val_ptr) => {
                     drop(ins.left);
-                    // SAFETY: We have consumed self.handle and the reference returned.
+                    // SAFETY: We have consumed self.handle and dropped the
+                    // remaining reference to the tree, ins.left.
                     let map = unsafe { self.dormant_map.awaken() };
-                    let root = map.root.as_mut().unwrap();
+                    let root = map.root.as_mut().unwrap(); // same as ins.left
                     root.push_internal_level().push(ins.kv.0, ins.kv.1, ins.right);
                     map.length += 1;
                     val_ptr