@@ -8,10 +8,13 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
8
8
/// sibling. If successful but at the cost of shrinking the parent node,
9
9
/// returns that shrunk parent node. Returns an `Err` if the node is
10
10
/// an empty root.
11
- fn fix_node_through_parent < A : Allocator > (
11
+ fn fix_node_through_parent < A > (
12
12
self ,
13
13
alloc : & A ,
14
- ) -> Result < Option < NodeRef < marker:: Mut < ' a > , K , V , marker:: Internal > > , Self > {
14
+ ) -> Result < Option < NodeRef < marker:: Mut < ' a > , K , V , marker:: Internal > > , Self >
15
+ where
16
+ A : Allocator ,
17
+ {
15
18
let len = self . len ( ) ;
16
19
if len >= MIN_LEN {
17
20
Ok ( None )
@@ -55,7 +58,10 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
55
58
///
56
59
/// This method does not expect ancestors to already be underfull upon entry
57
60
/// and panics if it encounters an empty ancestor.
58
- pub ( crate ) fn fix_node_and_affected_ancestors < A : Allocator > ( mut self , alloc : & A ) -> bool {
61
+ pub ( crate ) fn fix_node_and_affected_ancestors < A > ( mut self , alloc : & A ) -> bool
62
+ where
63
+ A : Allocator ,
64
+ {
59
65
loop {
60
66
match self . fix_node_through_parent ( alloc) {
61
67
Ok ( Some ( parent) ) => self = parent. forget_type ( ) ,
@@ -68,7 +74,10 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
68
74
69
75
impl < K , V > Root < K , V > {
70
76
/// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty.
71
- pub ( crate ) fn fix_top < A : Allocator > ( & mut self , alloc : & A ) {
77
+ pub ( crate ) fn fix_top < A > ( & mut self , alloc : & A )
78
+ where
79
+ A : Allocator ,
80
+ {
72
81
while self . height ( ) > 0 && self . len ( ) == 0 {
73
82
self . pop_internal_level ( alloc) ;
74
83
}
@@ -77,7 +86,10 @@ impl<K, V> Root<K, V> {
77
86
/// Stocks up or merge away any underfull nodes on the right border of the
78
87
/// tree. The other nodes, those that are not the root nor a rightmost edge,
79
88
/// must already have at least MIN_LEN elements.
80
- pub ( crate ) fn fix_right_border < A : Allocator > ( & mut self , alloc : & A ) {
89
+ pub ( crate ) fn fix_right_border < A > ( & mut self , alloc : & A )
90
+ where
91
+ A : Allocator ,
92
+ {
81
93
self . fix_top ( alloc) ;
82
94
if self . len ( ) > 0 {
83
95
self . borrow_mut ( )
@@ -88,7 +100,10 @@ impl<K, V> Root<K, V> {
88
100
}
89
101
90
102
/// The symmetric clone of `fix_right_border`.
91
- pub ( crate ) fn fix_left_border < A : Allocator > ( & mut self , alloc : & A ) {
103
+ pub ( crate ) fn fix_left_border < A > ( & mut self , alloc : & A )
104
+ where
105
+ A : Allocator ,
106
+ {
92
107
self . fix_top ( alloc) ;
93
108
if self . len ( ) > 0 {
94
109
self . borrow_mut ( )
@@ -120,14 +135,20 @@ impl<K, V> Root<K, V> {
120
135
}
121
136
122
137
impl < ' a , K : ' a , V : ' a > Handle < NodeRef < marker:: Mut < ' a > , K , V , marker:: LeafOrInternal > , marker:: KV > {
123
- fn fix_left_border_of_left_edge < A : Allocator > ( mut self , alloc : & A ) {
138
+ fn fix_left_border_of_left_edge < A > ( mut self , alloc : & A )
139
+ where
140
+ A : Allocator ,
141
+ {
124
142
while let Internal ( internal_kv) = self . force ( ) {
125
143
self = internal_kv. fix_left_child ( alloc) . first_kv ( ) ;
126
144
debug_assert ! ( self . reborrow( ) . into_node( ) . len( ) > MIN_LEN ) ;
127
145
}
128
146
}
129
147
130
- fn fix_right_border_of_right_edge < A : Allocator > ( mut self , alloc : & A ) {
148
+ fn fix_right_border_of_right_edge < A > ( mut self , alloc : & A )
149
+ where
150
+ A : Allocator ,
151
+ {
131
152
while let Internal ( internal_kv) = self . force ( ) {
132
153
self = internal_kv. fix_right_child ( alloc) . last_kv ( ) ;
133
154
debug_assert ! ( self . reborrow( ) . into_node( ) . len( ) > MIN_LEN ) ;
@@ -140,10 +161,10 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
140
161
/// provisions an extra element to allow merging its children in turn
141
162
/// without becoming underfull.
142
163
/// Returns the left child.
143
- fn fix_left_child < A : Allocator > (
144
- self ,
145
- alloc : & A ,
146
- ) -> NodeRef < marker :: Mut < ' a > , K , V , marker :: LeafOrInternal > {
164
+ fn fix_left_child < A > ( self , alloc : & A ) -> NodeRef < marker :: Mut < ' a > , K , V , marker :: LeafOrInternal >
165
+ where
166
+ A : Allocator ,
167
+ {
147
168
let mut internal_kv = self . consider_for_balancing ( ) ;
148
169
let left_len = internal_kv. left_child_len ( ) ;
149
170
debug_assert ! ( internal_kv. right_child_len( ) >= MIN_LEN ) ;
@@ -163,10 +184,10 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
163
184
/// provisions an extra element to allow merging its children in turn
164
185
/// without becoming underfull.
165
186
/// Returns wherever the right child ended up.
166
- fn fix_right_child < A : Allocator > (
167
- self ,
168
- alloc : & A ,
169
- ) -> NodeRef < marker :: Mut < ' a > , K , V , marker :: LeafOrInternal > {
187
+ fn fix_right_child < A > ( self , alloc : & A ) -> NodeRef < marker :: Mut < ' a > , K , V , marker :: LeafOrInternal >
188
+ where
189
+ A : Allocator ,
190
+ {
170
191
let mut internal_kv = self . consider_for_balancing ( ) ;
171
192
let right_len = internal_kv. right_child_len ( ) ;
172
193
debug_assert ! ( internal_kv. left_child_len( ) >= MIN_LEN ) ;
0 commit comments