@@ -157,7 +157,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
157157
158158 {
159159 let root = out_tree. root . as_mut ( ) . unwrap ( ) ; // unwrap succeeds because we just wrapped
160- let mut out_node = match root. node_as_mut ( ) . force ( ) {
160+ let mut out_node = match root. borrow_mut ( ) . force ( ) {
161161 Leaf ( leaf) => leaf,
162162 Internal ( _) => unreachable ! ( ) ,
163163 } ;
@@ -213,7 +213,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
213213 // Ord` constraint, which this method lacks.
214214 BTreeMap { root : None , length : 0 }
215215 } else {
216- clone_subtree ( self . root . as_ref ( ) . unwrap ( ) . node_as_ref ( ) ) // unwrap succeeds because not empty
216+ clone_subtree ( self . root . as_ref ( ) . unwrap ( ) . reborrow ( ) ) // unwrap succeeds because not empty
217217 }
218218 }
219219}
@@ -226,7 +226,7 @@ where
226226 type Key = K ;
227227
228228 fn get ( & self , key : & Q ) -> Option < & K > {
229- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
229+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
230230 match search:: search_tree ( root_node, key) {
231231 Found ( handle) => Some ( handle. into_kv ( ) . 0 ) ,
232232 GoDown ( _) => None ,
@@ -235,7 +235,7 @@ where
235235
236236 fn take ( & mut self , key : & Q ) -> Option < K > {
237237 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
238- let root_node = map. root . as_mut ( ) ?. node_as_mut ( ) ;
238+ let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
239239 match search:: search_tree ( root_node, key) {
240240 Found ( handle) => {
241241 Some ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } . remove_kv ( ) . 0 )
@@ -246,7 +246,7 @@ where
246246
247247 fn replace ( & mut self , key : K ) -> Option < K > {
248248 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
249- let root_node = Self :: ensure_is_owned ( & mut map. root ) . node_as_mut ( ) ;
249+ let root_node = Self :: ensure_is_owned ( & mut map. root ) . borrow_mut ( ) ;
250250 match search:: search_tree :: < marker:: Mut < ' _ > , K , ( ) , K > ( root_node, & key) {
251251 Found ( handle) => Some ( mem:: replace ( handle. into_key_mut ( ) , key) ) ,
252252 GoDown ( handle) => {
@@ -522,7 +522,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
522522 K : Borrow < Q > ,
523523 Q : Ord ,
524524 {
525- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
525+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
526526 match search:: search_tree ( root_node, key) {
527527 Found ( handle) => Some ( handle. into_kv ( ) . 1 ) ,
528528 GoDown ( _) => None ,
@@ -550,7 +550,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
550550 K : Borrow < Q > ,
551551 Q : Ord ,
552552 {
553- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
553+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
554554 match search:: search_tree ( root_node, k) {
555555 Found ( handle) => Some ( handle. into_kv ( ) ) ,
556556 GoDown ( _) => None ,
@@ -576,7 +576,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
576576 /// ```
577577 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
578578 pub fn first_key_value ( & self ) -> Option < ( & K , & V ) > {
579- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
579+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
580580 root_node. first_leaf_edge ( ) . right_kv ( ) . ok ( ) . map ( Handle :: into_kv)
581581 }
582582
@@ -603,7 +603,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
603603 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
604604 pub fn first_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
605605 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
606- let root_node = map. root . as_mut ( ) ?. node_as_mut ( ) ;
606+ let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
607607 let kv = root_node. first_leaf_edge ( ) . right_kv ( ) . ok ( ) ?;
608608 Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
609609 }
@@ -650,7 +650,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
650650 /// ```
651651 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
652652 pub fn last_key_value ( & self ) -> Option < ( & K , & V ) > {
653- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
653+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
654654 root_node. last_leaf_edge ( ) . left_kv ( ) . ok ( ) . map ( Handle :: into_kv)
655655 }
656656
@@ -677,7 +677,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
677677 #[ unstable( feature = "map_first_last" , issue = "62924" ) ]
678678 pub fn last_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
679679 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
680- let root_node = map. root . as_mut ( ) ?. node_as_mut ( ) ;
680+ let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
681681 let kv = root_node. last_leaf_edge ( ) . left_kv ( ) . ok ( ) ?;
682682 Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
683683 }
@@ -758,7 +758,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
758758 K : Borrow < Q > ,
759759 Q : Ord ,
760760 {
761- let root_node = self . root . as_mut ( ) ?. node_as_mut ( ) ;
761+ let root_node = self . root . as_mut ( ) ?. borrow_mut ( ) ;
762762 match search:: search_tree ( root_node, key) {
763763 Found ( handle) => Some ( handle. into_val_mut ( ) ) ,
764764 GoDown ( _) => None ,
@@ -854,7 +854,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
854854 Q : Ord ,
855855 {
856856 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
857- let root_node = map. root . as_mut ( ) ?. node_as_mut ( ) ;
857+ let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
858858 match search:: search_tree ( root_node, key) {
859859 Found ( handle) => {
860860 Some ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } . remove_entry ( ) )
@@ -971,7 +971,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
971971 R : RangeBounds < T > ,
972972 {
973973 if let Some ( root) = & self . root {
974- let ( f, b) = root. node_as_ref ( ) . range_search ( range) ;
974+ let ( f, b) = root. reborrow ( ) . range_search ( range) ;
975975
976976 Range { front : Some ( f) , back : Some ( b) }
977977 } else {
@@ -1017,7 +1017,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
10171017 R : RangeBounds < T > ,
10181018 {
10191019 if let Some ( root) = & mut self . root {
1020- let ( f, b) = root. node_as_valmut ( ) . range_search ( range) ;
1020+ let ( f, b) = root. borrow_valmut ( ) . range_search ( range) ;
10211021
10221022 RangeMut { front : Some ( f) , back : Some ( b) , _marker : PhantomData }
10231023 } else {
@@ -1047,7 +1047,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
10471047 pub fn entry ( & mut self , key : K ) -> Entry < ' _ , K , V > {
10481048 // FIXME(@porglezomp) Avoid allocating if we don't insert
10491049 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
1050- let root_node = Self :: ensure_is_owned ( & mut map. root ) . node_as_mut ( ) ;
1050+ let root_node = Self :: ensure_is_owned ( & mut map. root ) . borrow_mut ( ) ;
10511051 match search:: search_tree ( root_node, & key) {
10521052 Found ( handle) => Occupied ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } ) ,
10531053 GoDown ( handle) => {
@@ -1103,10 +1103,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
11031103 left_root. split_off ( right_root, key) ;
11041104
11051105 if left_root. height ( ) < right_root. height ( ) {
1106- self . length = left_root. node_as_ref ( ) . calc_length ( ) ;
1106+ self . length = left_root. reborrow ( ) . calc_length ( ) ;
11071107 right. length = total_num - self . len ( ) ;
11081108 } else {
1109- right. length = right_root. node_as_ref ( ) . calc_length ( ) ;
1109+ right. length = right_root. reborrow ( ) . calc_length ( ) ;
11101110 self . length = total_num - right. len ( ) ;
11111111 }
11121112
@@ -1154,7 +1154,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
11541154 pub ( super ) fn drain_filter_inner ( & mut self ) -> DrainFilterInner < ' _ , K , V > {
11551155 if let Some ( root) = self . root . as_mut ( ) {
11561156 let ( root, dormant_root) = DormantMutRef :: new ( root) ;
1157- let front = root. node_as_mut ( ) . first_leaf_edge ( ) ;
1157+ let front = root. borrow_mut ( ) . first_leaf_edge ( ) ;
11581158 DrainFilterInner {
11591159 length : & mut self . length ,
11601160 dormant_root : Some ( dormant_root) ,
@@ -1361,7 +1361,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
13611361 fn into_iter ( self ) -> IntoIter < K , V > {
13621362 let mut me = ManuallyDrop :: new ( self ) ;
13631363 if let Some ( root) = me. root . take ( ) {
1364- let ( f, b) = root. into_ref ( ) . full_range ( ) ;
1364+ let ( f, b) = root. full_range ( ) ;
13651365
13661366 IntoIter { front : Some ( f) , back : Some ( b) , length : me. length }
13671367 } else {
@@ -2007,7 +2007,7 @@ impl<K, V> BTreeMap<K, V> {
20072007 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
20082008 pub fn iter ( & self ) -> Iter < ' _ , K , V > {
20092009 if let Some ( root) = & self . root {
2010- let ( f, b) = root. node_as_ref ( ) . full_range ( ) ;
2010+ let ( f, b) = root. reborrow ( ) . full_range ( ) ;
20112011
20122012 Iter { range : Range { front : Some ( f) , back : Some ( b) } , length : self . length }
20132013 } else {
@@ -2039,7 +2039,7 @@ impl<K, V> BTreeMap<K, V> {
20392039 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
20402040 pub fn iter_mut ( & mut self ) -> IterMut < ' _ , K , V > {
20412041 if let Some ( root) = & mut self . root {
2042- let ( f, b) = root. node_as_valmut ( ) . full_range ( ) ;
2042+ let ( f, b) = root. borrow_valmut ( ) . full_range ( ) ;
20432043
20442044 IterMut {
20452045 range : RangeMut { front : Some ( f) , back : Some ( b) , _marker : PhantomData } ,
0 commit comments