1
- use core:: borrow:: Borrow ;
2
- use core:: cmp:: Ordering ;
1
+ use core:: cmp:: { Comparable , Ordering } ;
3
2
use core:: ops:: { Bound , RangeBounds } ;
4
3
5
4
use SearchBound :: * ;
@@ -51,8 +50,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
51
50
key : & Q ,
52
51
) -> SearchResult < BorrowType , K , V , marker:: LeafOrInternal , marker:: Leaf >
53
52
where
54
- Q : Ord ,
55
- K : Borrow < Q > ,
53
+ K : Comparable < Q > ,
56
54
{
57
55
loop {
58
56
self = match self . search_node ( key) {
@@ -95,7 +93,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
95
93
>
96
94
where
97
95
Q : Ord ,
98
- K : Borrow < Q > ,
96
+ K : Comparable < Q > ,
99
97
R : RangeBounds < Q > ,
100
98
{
101
99
// Determine if map or set is being searched
@@ -161,8 +159,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
161
159
bound : SearchBound < & ' r Q > ,
162
160
) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
163
161
where
164
- Q : ?Sized + Ord ,
165
- K : Borrow < Q > ,
162
+ Q : ?Sized ,
163
+ K : Comparable < Q > ,
166
164
{
167
165
let ( edge_idx, bound) = self . find_lower_bound_index ( bound) ;
168
166
let edge = unsafe { Handle :: new_edge ( self , edge_idx) } ;
@@ -175,8 +173,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
175
173
bound : SearchBound < & ' r Q > ,
176
174
) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
177
175
where
178
- Q : ?Sized + Ord ,
179
- K : Borrow < Q > ,
176
+ Q : ?Sized ,
177
+ K : Comparable < Q > ,
180
178
{
181
179
let ( edge_idx, bound) = unsafe { self . find_upper_bound_index ( bound, 0 ) } ;
182
180
let edge = unsafe { Handle :: new_edge ( self , edge_idx) } ;
@@ -197,8 +195,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
197
195
key : & Q ,
198
196
) -> SearchResult < BorrowType , K , V , Type , Type >
199
197
where
200
- Q : Ord ,
201
- K : Borrow < Q > ,
198
+ K : Comparable < Q > ,
202
199
{
203
200
match unsafe { self . find_key_index ( key, 0 ) } {
204
201
IndexResult :: KV ( idx) => Found ( unsafe { Handle :: new_kv ( self , idx) } ) ,
@@ -216,17 +213,16 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
216
213
/// `start_index` must be a valid edge index for the node.
217
214
unsafe fn find_key_index < Q : ?Sized > ( & self , key : & Q , start_index : usize ) -> IndexResult
218
215
where
219
- Q : Ord ,
220
- K : Borrow < Q > ,
216
+ K : Comparable < Q > ,
221
217
{
222
218
let node = self . reborrow ( ) ;
223
219
let keys = node. keys ( ) ;
224
220
debug_assert ! ( start_index <= keys. len( ) ) ;
225
221
for ( offset, k) in unsafe { keys. get_unchecked ( start_index..) } . iter ( ) . enumerate ( ) {
226
- match key . cmp ( k . borrow ( ) ) {
227
- Ordering :: Greater => { }
222
+ match k . compare ( key ) {
223
+ Ordering :: Less => { }
228
224
Ordering :: Equal => return IndexResult :: KV ( start_index + offset) ,
229
- Ordering :: Less => return IndexResult :: Edge ( start_index + offset) ,
225
+ Ordering :: Greater => return IndexResult :: Edge ( start_index + offset) ,
230
226
}
231
227
}
232
228
IndexResult :: Edge ( keys. len ( ) )
@@ -242,8 +238,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
242
238
bound : SearchBound < & ' r Q > ,
243
239
) -> ( usize , SearchBound < & ' r Q > )
244
240
where
245
- Q : ?Sized + Ord ,
246
- K : Borrow < Q > ,
241
+ Q : ?Sized ,
242
+ K : Comparable < Q > ,
247
243
{
248
244
match bound {
249
245
Included ( key) => match unsafe { self . find_key_index ( key, 0 ) } {
@@ -270,8 +266,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
270
266
start_index : usize ,
271
267
) -> ( usize , SearchBound < & ' r Q > )
272
268
where
273
- Q : ?Sized + Ord ,
274
- K : Borrow < Q > ,
269
+ Q : ?Sized ,
270
+ K : Comparable < Q > ,
275
271
{
276
272
match bound {
277
273
Included ( key) => match unsafe { self . find_key_index ( key, start_index) } {
0 commit comments