Skip to content

Commit

Permalink
BTreeMap: relax the explicit borrow rule to make code shorter and safer
Browse files Browse the repository at this point in the history
  • Loading branch information
ssomers committed Dec 17, 2020
1 parent d23e084 commit 29114ff
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 106 deletions.
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ where
let (map, dormant_map) = DormantMutRef::new(self);
let root_node = Self::ensure_is_owned(&mut map.root).borrow_mut();
match search::search_tree::<marker::Mut<'_>, K, (), K>(root_node, &key) {
Found(handle) => Some(mem::replace(handle.into_key_mut(), key)),
Found(mut kv) => Some(mem::replace(kv.key_mut(), key)),
GoDown(handle) => {
VacantEntry { key, handle, dormant_map, _marker: PhantomData }.insert(());
None
Expand Down
Loading

0 comments on commit 29114ff

Please sign in to comment.