Skip to content

Commit d71d13e

Browse files
committed
BTreeMap: refactoring around edges, missed spots
1 parent fc42fb8 commit d71d13e

File tree

1 file changed

+7
-7
lines changed
  • library/alloc/src/collections/btree

1 file changed

+7
-7
lines changed

library/alloc/src/collections/btree/node.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -484,15 +484,15 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
484484
///
485485
/// # Safety
486486
/// The node has more than `idx` initialized elements.
487-
pub unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
487+
unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
488488
unsafe { self.reborrow_mut().into_key_mut_at(idx) }
489489
}
490490

491491
/// Borrows a mutable reference to one of the values stored in the node.
492492
///
493493
/// # Safety
494494
/// The node has more than `idx` initialized elements.
495-
pub unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
495+
unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
496496
unsafe { self.reborrow_mut().into_val_mut_at(idx) }
497497
}
498498

@@ -655,7 +655,7 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
655655

656656
/// Adds a key/value pair, and an edge to go to the left of that pair,
657657
/// to the beginning of the node.
658-
pub fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
658+
fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
659659
assert!(edge.height == self.height - 1);
660660
assert!(self.len() < CAPACITY);
661661

@@ -1011,18 +1011,18 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
10111011
let (middle_kv_idx, insertion) = splitpoint(self.idx);
10121012
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
10131013
let (mut left, k, v, mut right) = middle.split();
1014-
match insertion {
1014+
let mut insertion_edge = match insertion {
10151015
InsertionPlace::Left(insert_idx) => unsafe {
1016-
Handle::new_edge(left.reborrow_mut(), insert_idx).insert_fit(key, val, edge);
1016+
Handle::new_edge(left.reborrow_mut(), insert_idx)
10171017
},
10181018
InsertionPlace::Right(insert_idx) => unsafe {
10191019
Handle::new_edge(
10201020
right.node_as_mut().cast_unchecked::<marker::Internal>(),
10211021
insert_idx,
10221022
)
1023-
.insert_fit(key, val, edge);
10241023
},
1025-
}
1024+
};
1025+
insertion_edge.insert_fit(key, val, edge);
10261026
InsertResult::Split(SplitResult { left: left.forget_type(), k, v, right })
10271027
}
10281028
}

0 commit comments

Comments
 (0)