@@ -7,9 +7,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
7
7
/// sibling. If successful but at the cost of shrinking the parent node,
8
8
/// returns that shrunk parent node. Returns an `Err` if the node is
9
9
/// an empty root.
10
- fn fix_node_through_parent < A : Allocator > (
10
+ fn fix_node_through_parent < A : Allocator + Clone > (
11
11
self ,
12
- alloc : & A ,
12
+ alloc : A ,
13
13
) -> Result < Option < NodeRef < marker:: Mut < ' a > , K , V , marker:: Internal > > , Self > {
14
14
let len = self . len ( ) ;
15
15
if len >= MIN_LEN {
@@ -54,9 +54,9 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
54
54
///
55
55
/// This method does not expect ancestors to already be underfull upon entry
56
56
/// and panics if it encounters an empty ancestor.
57
- pub fn fix_node_and_affected_ancestors < A : Allocator > ( mut self , alloc : & A ) -> bool {
57
+ pub fn fix_node_and_affected_ancestors < A : Allocator + Clone > ( mut self , alloc : A ) -> bool {
58
58
loop {
59
- match self . fix_node_through_parent ( alloc) {
59
+ match self . fix_node_through_parent ( alloc. clone ( ) ) {
60
60
Ok ( Some ( parent) ) => self = parent. forget_type ( ) ,
61
61
Ok ( None ) => return true ,
62
62
Err ( _) => return false ,
@@ -67,28 +67,28 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
67
67
68
68
impl < K , V > Root < K , V > {
69
69
/// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty.
70
- pub fn fix_top < A : Allocator > ( & mut self , alloc : & A ) {
70
+ pub fn fix_top < A : Allocator + Clone > ( & mut self , alloc : A ) {
71
71
while self . height ( ) > 0 && self . len ( ) == 0 {
72
- self . pop_internal_level ( alloc) ;
72
+ self . pop_internal_level ( alloc. clone ( ) ) ;
73
73
}
74
74
}
75
75
76
76
/// Stocks up or merge away any underfull nodes on the right border of the
77
77
/// tree. The other nodes, those that are not the root nor a rightmost edge,
78
78
/// must already have at least MIN_LEN elements.
79
- pub fn fix_right_border < A : Allocator > ( & mut self , alloc : & A ) {
80
- self . fix_top ( alloc) ;
79
+ pub fn fix_right_border < A : Allocator + Clone > ( & mut self , alloc : A ) {
80
+ self . fix_top ( alloc. clone ( ) ) ;
81
81
if self . len ( ) > 0 {
82
- self . borrow_mut ( ) . last_kv ( ) . fix_right_border_of_right_edge ( alloc) ;
82
+ self . borrow_mut ( ) . last_kv ( ) . fix_right_border_of_right_edge ( alloc. clone ( ) ) ;
83
83
self . fix_top ( alloc) ;
84
84
}
85
85
}
86
86
87
87
/// The symmetric clone of `fix_right_border`.
88
- pub fn fix_left_border < A : Allocator > ( & mut self , alloc : & A ) {
89
- self . fix_top ( alloc) ;
88
+ pub fn fix_left_border < A : Allocator + Clone > ( & mut self , alloc : A ) {
89
+ self . fix_top ( alloc. clone ( ) ) ;
90
90
if self . len ( ) > 0 {
91
- self . borrow_mut ( ) . first_kv ( ) . fix_left_border_of_left_edge ( alloc) ;
91
+ self . borrow_mut ( ) . first_kv ( ) . fix_left_border_of_left_edge ( alloc. clone ( ) ) ;
92
92
self . fix_top ( alloc) ;
93
93
}
94
94
}
@@ -115,16 +115,16 @@ impl<K, V> Root<K, V> {
115
115
}
116
116
117
117
impl < ' a , K : ' a , V : ' a > Handle < NodeRef < marker:: Mut < ' a > , K , V , marker:: LeafOrInternal > , marker:: KV > {
118
- fn fix_left_border_of_left_edge < A : Allocator > ( mut self , alloc : & A ) {
118
+ fn fix_left_border_of_left_edge < A : Allocator + Clone > ( mut self , alloc : A ) {
119
119
while let Internal ( internal_kv) = self . force ( ) {
120
- self = internal_kv. fix_left_child ( alloc) . first_kv ( ) ;
120
+ self = internal_kv. fix_left_child ( alloc. clone ( ) ) . first_kv ( ) ;
121
121
debug_assert ! ( self . reborrow( ) . into_node( ) . len( ) > MIN_LEN ) ;
122
122
}
123
123
}
124
124
125
- fn fix_right_border_of_right_edge < A : Allocator > ( mut self , alloc : & A ) {
125
+ fn fix_right_border_of_right_edge < A : Allocator + Clone > ( mut self , alloc : A ) {
126
126
while let Internal ( internal_kv) = self . force ( ) {
127
- self = internal_kv. fix_right_child ( alloc) . last_kv ( ) ;
127
+ self = internal_kv. fix_right_child ( alloc. clone ( ) ) . last_kv ( ) ;
128
128
debug_assert ! ( self . reborrow( ) . into_node( ) . len( ) > MIN_LEN ) ;
129
129
}
130
130
}
@@ -135,9 +135,9 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
135
135
/// provisions an extra element to allow merging its children in turn
136
136
/// without becoming underfull.
137
137
/// Returns the left child.
138
- fn fix_left_child < A : Allocator > (
138
+ fn fix_left_child < A : Allocator + Clone > (
139
139
self ,
140
- alloc : & A ,
140
+ alloc : A ,
141
141
) -> NodeRef < marker:: Mut < ' a > , K , V , marker:: LeafOrInternal > {
142
142
let mut internal_kv = self . consider_for_balancing ( ) ;
143
143
let left_len = internal_kv. left_child_len ( ) ;
@@ -158,9 +158,9 @@ impl<'a, K: 'a, V: 'a> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Internal>,
158
158
/// provisions an extra element to allow merging its children in turn
159
159
/// without becoming underfull.
160
160
/// Returns wherever the right child ended up.
161
- fn fix_right_child < A : Allocator > (
161
+ fn fix_right_child < A : Allocator + Clone > (
162
162
self ,
163
- alloc : & A ,
163
+ alloc : A ,
164
164
) -> NodeRef < marker:: Mut < ' a > , K , V , marker:: LeafOrInternal > {
165
165
let mut internal_kv = self . consider_for_balancing ( ) ;
166
166
let right_len = internal_kv. right_child_len ( ) ;
0 commit comments