1- use core:: borrow:: Borrow ;
2- use core:: cmp:: Ordering ;
1+ use core:: cmp:: { Comparable , Ordering } ;
32use core:: ops:: { Bound , RangeBounds } ;
43
54use SearchBound :: * ;
@@ -51,8 +50,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
5150 key : & Q ,
5251 ) -> SearchResult < BorrowType , K , V , marker:: LeafOrInternal , marker:: Leaf >
5352 where
54- Q : Ord ,
55- K : Borrow < Q > ,
53+ K : Comparable < Q > ,
5654 {
5755 loop {
5856 self = match self . search_node ( key) {
@@ -95,7 +93,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
9593 >
9694 where
9795 Q : Ord ,
98- K : Borrow < Q > ,
96+ K : Comparable < Q > ,
9997 R : RangeBounds < Q > ,
10098 {
10199 // Determine if map or set is being searched
@@ -161,8 +159,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
161159 bound : SearchBound < & ' r Q > ,
162160 ) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
163161 where
164- Q : ?Sized + Ord ,
165- K : Borrow < Q > ,
162+ Q : ?Sized ,
163+ K : Comparable < Q > ,
166164 {
167165 let ( edge_idx, bound) = self . find_lower_bound_index ( bound) ;
168166 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
175173 bound : SearchBound < & ' r Q > ,
176174 ) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
177175 where
178- Q : ?Sized + Ord ,
179- K : Borrow < Q > ,
176+ Q : ?Sized ,
177+ K : Comparable < Q > ,
180178 {
181179 let ( edge_idx, bound) = unsafe { self . find_upper_bound_index ( bound, 0 ) } ;
182180 let edge = unsafe { Handle :: new_edge ( self , edge_idx) } ;
@@ -197,8 +195,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
197195 key : & Q ,
198196 ) -> SearchResult < BorrowType , K , V , Type , Type >
199197 where
200- Q : Ord ,
201- K : Borrow < Q > ,
198+ K : Comparable < Q > ,
202199 {
203200 match unsafe { self . find_key_index ( key, 0 ) } {
204201 IndexResult :: KV ( idx) => Found ( unsafe { Handle :: new_kv ( self , idx) } ) ,
@@ -216,17 +213,16 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
216213 /// `start_index` must be a valid edge index for the node.
217214 unsafe fn find_key_index < Q : ?Sized > ( & self , key : & Q , start_index : usize ) -> IndexResult
218215 where
219- Q : Ord ,
220- K : Borrow < Q > ,
216+ K : Comparable < Q > ,
221217 {
222218 let node = self . reborrow ( ) ;
223219 let keys = node. keys ( ) ;
224220 debug_assert ! ( start_index <= keys. len( ) ) ;
225221 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 => { }
228224 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) ,
230226 }
231227 }
232228 IndexResult :: Edge ( keys. len ( ) )
@@ -242,8 +238,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
242238 bound : SearchBound < & ' r Q > ,
243239 ) -> ( usize , SearchBound < & ' r Q > )
244240 where
245- Q : ?Sized + Ord ,
246- K : Borrow < Q > ,
241+ Q : ?Sized ,
242+ K : Comparable < Q > ,
247243 {
248244 match bound {
249245 Included ( key) => match unsafe { self . find_key_index ( key, 0 ) } {
@@ -270,8 +266,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
270266 start_index : usize ,
271267 ) -> ( usize , SearchBound < & ' r Q > )
272268 where
273- Q : ?Sized + Ord ,
274- K : Borrow < Q > ,
269+ Q : ?Sized ,
270+ K : Comparable < Q > ,
275271 {
276272 match bound {
277273 Included ( key) => match unsafe { self . find_key_index ( key, start_index) } {
0 commit comments