Skip to content

Commit 23b1e3d

Browse files
authored
Rollup merge of #77471 - ssomers:btree_cleanup_3, r=Mark-Simulacrum
BTreeMap: refactoring around edges, missed spots Tweaks from #77244 (and more) that are really inconsistencies in #77005. r? @Mark-Simulacrum
2 parents e032bb7 + d71d13e commit 23b1e3d

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
@@ -474,15 +474,15 @@ impl<'a, K, V, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
474474
///
475475
/// # Safety
476476
/// The node has more than `idx` initialized elements.
477-
pub unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
477+
unsafe fn key_mut_at(&mut self, idx: usize) -> &mut K {
478478
unsafe { self.reborrow_mut().into_key_mut_at(idx) }
479479
}
480480

481481
/// Borrows a mutable reference to one of the values stored in the node.
482482
///
483483
/// # Safety
484484
/// The node has more than `idx` initialized elements.
485-
pub unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
485+
unsafe fn val_mut_at(&mut self, idx: usize) -> &mut V {
486486
unsafe { self.reborrow_mut().into_val_mut_at(idx) }
487487
}
488488

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

646646
/// Adds a key/value pair, and an edge to go to the left of that pair,
647647
/// to the beginning of the node.
648-
pub fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
648+
fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
649649
assert!(edge.height == self.height - 1);
650650
assert!(self.len() < CAPACITY);
651651

@@ -1001,18 +1001,18 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
10011001
let (middle_kv_idx, insertion) = splitpoint(self.idx);
10021002
let middle = unsafe { Handle::new_kv(self.node, middle_kv_idx) };
10031003
let (mut left, k, v, mut right) = middle.split();
1004-
match insertion {
1004+
let mut insertion_edge = match insertion {
10051005
InsertionPlace::Left(insert_idx) => unsafe {
1006-
Handle::new_edge(left.reborrow_mut(), insert_idx).insert_fit(key, val, edge);
1006+
Handle::new_edge(left.reborrow_mut(), insert_idx)
10071007
},
10081008
InsertionPlace::Right(insert_idx) => unsafe {
10091009
Handle::new_edge(
10101010
right.node_as_mut().cast_unchecked::<marker::Internal>(),
10111011
insert_idx,
10121012
)
1013-
.insert_fit(key, val, edge);
10141013
},
1015-
}
1014+
};
1015+
insertion_edge.insert_fit(key, val, edge);
10161016
InsertResult::Split(SplitResult { left: left.forget_type(), k, v, right })
10171017
}
10181018
}

0 commit comments

Comments
 (0)