1- use core:: borrow:: Borrow ;
21use core:: cmp:: Ordering ;
32use core:: ops:: { Bound , RangeBounds } ;
43
54use SearchBound :: * ;
65use SearchResult :: * ;
76
7+ use super :: cmp:: Comparable ;
88use super :: node:: ForceResult :: * ;
99use super :: node:: { Handle , NodeRef , marker} ;
1010
@@ -51,8 +51,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
5151 key : & Q ,
5252 ) -> SearchResult < BorrowType , K , V , marker:: LeafOrInternal , marker:: Leaf >
5353 where
54- Q : Ord ,
55- K : Borrow < Q > ,
54+ K : Comparable < Q > ,
5655 {
5756 loop {
5857 self = match self . search_node ( key) {
@@ -95,7 +94,7 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
9594 >
9695 where
9796 Q : Ord ,
98- K : Borrow < Q > ,
97+ K : Comparable < Q > ,
9998 R : RangeBounds < Q > ,
10099 {
101100 // Determine if map or set is being searched
@@ -161,8 +160,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
161160 bound : SearchBound < & ' r Q > ,
162161 ) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
163162 where
164- Q : ?Sized + Ord ,
165- K : Borrow < Q > ,
163+ Q : ?Sized ,
164+ K : Comparable < Q > ,
166165 {
167166 let ( edge_idx, bound) = self . find_lower_bound_index ( bound) ;
168167 let edge = unsafe { Handle :: new_edge ( self , edge_idx) } ;
@@ -175,8 +174,8 @@ impl<BorrowType: marker::BorrowType, K, V> NodeRef<BorrowType, K, V, marker::Lea
175174 bound : SearchBound < & ' r Q > ,
176175 ) -> ( Handle < Self , marker:: Edge > , SearchBound < & ' r Q > )
177176 where
178- Q : ?Sized + Ord ,
179- K : Borrow < Q > ,
177+ Q : ?Sized ,
178+ K : Comparable < Q > ,
180179 {
181180 let ( edge_idx, bound) = unsafe { self . find_upper_bound_index ( bound, 0 ) } ;
182181 let edge = unsafe { Handle :: new_edge ( self , edge_idx) } ;
@@ -197,8 +196,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
197196 key : & Q ,
198197 ) -> SearchResult < BorrowType , K , V , Type , Type >
199198 where
200- Q : Ord ,
201- K : Borrow < Q > ,
199+ K : Comparable < Q > ,
202200 {
203201 match unsafe { self . find_key_index ( key, 0 ) } {
204202 IndexResult :: KV ( idx) => Found ( unsafe { Handle :: new_kv ( self , idx) } ) ,
@@ -216,17 +214,16 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
216214 /// `start_index` must be a valid edge index for the node.
217215 unsafe fn find_key_index < Q : ?Sized > ( & self , key : & Q , start_index : usize ) -> IndexResult
218216 where
219- Q : Ord ,
220- K : Borrow < Q > ,
217+ K : Comparable < Q > ,
221218 {
222219 let node = self . reborrow ( ) ;
223220 let keys = node. keys ( ) ;
224221 debug_assert ! ( start_index <= keys. len( ) ) ;
225222 for ( offset, k) in unsafe { keys. get_unchecked ( start_index..) } . iter ( ) . enumerate ( ) {
226- match key . cmp ( k . borrow ( ) ) {
227- Ordering :: Greater => { }
223+ match k . compare ( key ) {
224+ Ordering :: Less => { }
228225 Ordering :: Equal => return IndexResult :: KV ( start_index + offset) ,
229- Ordering :: Less => return IndexResult :: Edge ( start_index + offset) ,
226+ Ordering :: Greater => return IndexResult :: Edge ( start_index + offset) ,
230227 }
231228 }
232229 IndexResult :: Edge ( keys. len ( ) )
@@ -242,8 +239,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
242239 bound : SearchBound < & ' r Q > ,
243240 ) -> ( usize , SearchBound < & ' r Q > )
244241 where
245- Q : ?Sized + Ord ,
246- K : Borrow < Q > ,
242+ Q : ?Sized ,
243+ K : Comparable < Q > ,
247244 {
248245 match bound {
249246 Included ( key) => match unsafe { self . find_key_index ( key, 0 ) } {
@@ -270,8 +267,8 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
270267 start_index : usize ,
271268 ) -> ( usize , SearchBound < & ' r Q > )
272269 where
273- Q : ?Sized + Ord ,
274- K : Borrow < Q > ,
270+ Q : ?Sized ,
271+ K : Comparable < Q > ,
275272 {
276273 match bound {
277274 Included ( key) => match unsafe { self . find_key_index ( key, start_index) } {
0 commit comments