Skip to content

Commit 29114ff

Browse files
committed
BTreeMap: relax the explicit borrow rule to make code shorter and safer
1 parent d23e084 commit 29114ff

File tree

2 files changed

+108
-106
lines changed

2 files changed

+108
-106
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ where
248248
let (map, dormant_map) = DormantMutRef::new(self);
249249
let root_node = Self::ensure_is_owned(&mut map.root).borrow_mut();
250250
match search::search_tree::<marker::Mut<'_>, K, (), K>(root_node, &key) {
251-
Found(handle) => Some(mem::replace(handle.into_key_mut(), key)),
251+
Found(mut kv) => Some(mem::replace(kv.key_mut(), key)),
252252
GoDown(handle) => {
253253
VacantEntry { key, handle, dormant_map, _marker: PhantomData }.insert(());
254254
None

0 commit comments

Comments
 (0)