@@ -157,7 +157,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
157
157
158
158
{
159
159
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 ( ) {
161
161
Leaf ( leaf) => leaf,
162
162
Internal ( _) => unreachable ! ( ) ,
163
163
} ;
@@ -213,7 +213,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
213
213
// Ord` constraint, which this method lacks.
214
214
BTreeMap { root : None , length : 0 }
215
215
} 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
217
217
}
218
218
}
219
219
}
@@ -226,7 +226,7 @@ where
226
226
type Key = K ;
227
227
228
228
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 ( ) ;
230
230
match search:: search_tree ( root_node, key) {
231
231
Found ( handle) => Some ( handle. into_kv ( ) . 0 ) ,
232
232
GoDown ( _) => None ,
@@ -235,7 +235,7 @@ where
235
235
236
236
fn take ( & mut self , key : & Q ) -> Option < K > {
237
237
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 ( ) ;
239
239
match search:: search_tree ( root_node, key) {
240
240
Found ( handle) => {
241
241
Some ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } . remove_kv ( ) . 0 )
@@ -246,7 +246,7 @@ where
246
246
247
247
fn replace ( & mut self , key : K ) -> Option < K > {
248
248
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 ( ) ;
250
250
match search:: search_tree :: < marker:: Mut < ' _ > , K , ( ) , K > ( root_node, & key) {
251
251
Found ( handle) => Some ( mem:: replace ( handle. into_key_mut ( ) , key) ) ,
252
252
GoDown ( handle) => {
@@ -522,7 +522,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
522
522
K : Borrow < Q > ,
523
523
Q : Ord ,
524
524
{
525
- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
525
+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
526
526
match search:: search_tree ( root_node, key) {
527
527
Found ( handle) => Some ( handle. into_kv ( ) . 1 ) ,
528
528
GoDown ( _) => None ,
@@ -550,7 +550,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
550
550
K : Borrow < Q > ,
551
551
Q : Ord ,
552
552
{
553
- let root_node = self . root . as_ref ( ) ?. node_as_ref ( ) ;
553
+ let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
554
554
match search:: search_tree ( root_node, k) {
555
555
Found ( handle) => Some ( handle. into_kv ( ) ) ,
556
556
GoDown ( _) => None ,
@@ -576,7 +576,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
576
576
/// ```
577
577
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
578
578
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 ( ) ;
580
580
root_node. first_leaf_edge ( ) . right_kv ( ) . ok ( ) . map ( Handle :: into_kv)
581
581
}
582
582
@@ -603,7 +603,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
603
603
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
604
604
pub fn first_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
605
605
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 ( ) ;
607
607
let kv = root_node. first_leaf_edge ( ) . right_kv ( ) . ok ( ) ?;
608
608
Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
609
609
}
@@ -650,7 +650,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
650
650
/// ```
651
651
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
652
652
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 ( ) ;
654
654
root_node. last_leaf_edge ( ) . left_kv ( ) . ok ( ) . map ( Handle :: into_kv)
655
655
}
656
656
@@ -677,7 +677,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
677
677
#[ unstable( feature = "map_first_last" , issue = "62924" ) ]
678
678
pub fn last_entry ( & mut self ) -> Option < OccupiedEntry < ' _ , K , V > > {
679
679
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 ( ) ;
681
681
let kv = root_node. last_leaf_edge ( ) . left_kv ( ) . ok ( ) ?;
682
682
Some ( OccupiedEntry { handle : kv. forget_node_type ( ) , dormant_map, _marker : PhantomData } )
683
683
}
@@ -758,7 +758,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
758
758
K : Borrow < Q > ,
759
759
Q : Ord ,
760
760
{
761
- let root_node = self . root . as_mut ( ) ?. node_as_mut ( ) ;
761
+ let root_node = self . root . as_mut ( ) ?. borrow_mut ( ) ;
762
762
match search:: search_tree ( root_node, key) {
763
763
Found ( handle) => Some ( handle. into_val_mut ( ) ) ,
764
764
GoDown ( _) => None ,
@@ -854,7 +854,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
854
854
Q : Ord ,
855
855
{
856
856
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 ( ) ;
858
858
match search:: search_tree ( root_node, key) {
859
859
Found ( handle) => {
860
860
Some ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } . remove_entry ( ) )
@@ -971,7 +971,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
971
971
R : RangeBounds < T > ,
972
972
{
973
973
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) ;
975
975
976
976
Range { front : Some ( f) , back : Some ( b) }
977
977
} else {
@@ -1017,7 +1017,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1017
1017
R : RangeBounds < T > ,
1018
1018
{
1019
1019
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) ;
1021
1021
1022
1022
RangeMut { front : Some ( f) , back : Some ( b) , _marker : PhantomData }
1023
1023
} else {
@@ -1047,7 +1047,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1047
1047
pub fn entry ( & mut self , key : K ) -> Entry < ' _ , K , V > {
1048
1048
// FIXME(@porglezomp) Avoid allocating if we don't insert
1049
1049
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 ( ) ;
1051
1051
match search:: search_tree ( root_node, & key) {
1052
1052
Found ( handle) => Occupied ( OccupiedEntry { handle, dormant_map, _marker : PhantomData } ) ,
1053
1053
GoDown ( handle) => {
@@ -1103,10 +1103,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
1103
1103
left_root. split_off ( right_root, key) ;
1104
1104
1105
1105
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 ( ) ;
1107
1107
right. length = total_num - self . len ( ) ;
1108
1108
} else {
1109
- right. length = right_root. node_as_ref ( ) . calc_length ( ) ;
1109
+ right. length = right_root. reborrow ( ) . calc_length ( ) ;
1110
1110
self . length = total_num - right. len ( ) ;
1111
1111
}
1112
1112
@@ -1154,7 +1154,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
1154
1154
pub ( super ) fn drain_filter_inner ( & mut self ) -> DrainFilterInner < ' _ , K , V > {
1155
1155
if let Some ( root) = self . root . as_mut ( ) {
1156
1156
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 ( ) ;
1158
1158
DrainFilterInner {
1159
1159
length : & mut self . length ,
1160
1160
dormant_root : Some ( dormant_root) ,
@@ -1361,7 +1361,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
1361
1361
fn into_iter ( self ) -> IntoIter < K , V > {
1362
1362
let mut me = ManuallyDrop :: new ( self ) ;
1363
1363
if let Some ( root) = me. root . take ( ) {
1364
- let ( f, b) = root. into_ref ( ) . full_range ( ) ;
1364
+ let ( f, b) = root. full_range ( ) ;
1365
1365
1366
1366
IntoIter { front : Some ( f) , back : Some ( b) , length : me. length }
1367
1367
} else {
@@ -2007,7 +2007,7 @@ impl<K, V> BTreeMap<K, V> {
2007
2007
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2008
2008
pub fn iter ( & self ) -> Iter < ' _ , K , V > {
2009
2009
if let Some ( root) = & self . root {
2010
- let ( f, b) = root. node_as_ref ( ) . full_range ( ) ;
2010
+ let ( f, b) = root. reborrow ( ) . full_range ( ) ;
2011
2011
2012
2012
Iter { range : Range { front : Some ( f) , back : Some ( b) } , length : self . length }
2013
2013
} else {
@@ -2039,7 +2039,7 @@ impl<K, V> BTreeMap<K, V> {
2039
2039
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2040
2040
pub fn iter_mut ( & mut self ) -> IterMut < ' _ , K , V > {
2041
2041
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 ( ) ;
2043
2043
2044
2044
IterMut {
2045
2045
range : RangeMut { front : Some ( f) , back : Some ( b) , _marker : PhantomData } ,
0 commit comments