1- use core:: borrow:: Borrow ;
2- use core:: cmp:: Ordering ;
1+ use core:: cmp:: { Comparable , Ordering } ;
32use core:: error:: Error ;
43use core:: fmt:: { self , Debug } ;
54use core:: hash:: { Hash , Hasher } ;
@@ -332,8 +331,7 @@ impl<K, A: Allocator + Clone> BTreeMap<K, SetValZST, A> {
332331
333332 pub ( super ) fn get_or_insert_with < Q : ?Sized , F > ( & mut self , q : & Q , f : F ) -> & K
334333 where
335- K : Borrow < Q > + Ord ,
336- Q : Ord ,
334+ K : Comparable < Q > + Ord ,
337335 F : FnOnce ( & Q ) -> K ,
338336 {
339337 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
@@ -343,7 +341,7 @@ impl<K, A: Allocator + Clone> BTreeMap<K, SetValZST, A> {
343341 Found ( handle) => handle. into_kv_mut ( ) . 0 ,
344342 GoDown ( handle) => {
345343 let key = f ( q) ;
346- assert ! ( * key. borrow ( ) == * q , "new value is not equal" ) ;
344+ assert ! ( key. equivalent ( q ) , "new value is not equal" ) ;
347345 VacantEntry {
348346 key,
349347 handle : Some ( handle) ,
@@ -710,8 +708,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
710708 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
711709 pub fn get < Q : ?Sized > ( & self , key : & Q ) -> Option < & V >
712710 where
713- K : Borrow < Q > + Ord ,
714- Q : Ord ,
711+ K : Comparable < Q > + Ord ,
715712 {
716713 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
717714 match root_node. search_tree ( key) {
@@ -776,8 +773,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
776773 #[ stable( feature = "map_get_key_value" , since = "1.40.0" ) ]
777774 pub fn get_key_value < Q : ?Sized > ( & self , k : & Q ) -> Option < ( & K , & V ) >
778775 where
779- K : Borrow < Q > + Ord ,
780- Q : Ord ,
776+ K : Comparable < Q > + Ord ,
781777 {
782778 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
783779 match root_node. search_tree ( k) {
@@ -972,8 +968,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
972968 #[ cfg_attr( not( test) , rustc_diagnostic_item = "btreemap_contains_key" ) ]
973969 pub fn contains_key < Q : ?Sized > ( & self , key : & Q ) -> bool
974970 where
975- K : Borrow < Q > + Ord ,
976- Q : Ord ,
971+ K : Comparable < Q > + Ord ,
977972 {
978973 self . get ( key) . is_some ( )
979974 }
@@ -999,8 +994,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
999994 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1000995 pub fn get_mut < Q : ?Sized > ( & mut self , key : & Q ) -> Option < & mut V >
1001996 where
1002- K : Borrow < Q > + Ord ,
1003- Q : Ord ,
997+ K : Comparable < Q > + Ord ,
1004998 {
1005999 let root_node = self . root . as_mut ( ) ?. borrow_mut ( ) ;
10061000 match root_node. search_tree ( key) {
@@ -1101,8 +1095,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
11011095 #[ rustc_confusables( "delete" , "take" ) ]
11021096 pub fn remove < Q : ?Sized > ( & mut self , key : & Q ) -> Option < V >
11031097 where
1104- K : Borrow < Q > + Ord ,
1105- Q : Ord ,
1098+ K : Comparable < Q > + Ord ,
11061099 {
11071100 self . remove_entry ( key) . map ( |( _, v) | v)
11081101 }
@@ -1126,8 +1119,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
11261119 #[ stable( feature = "btreemap_remove_entry" , since = "1.45.0" ) ]
11271120 pub fn remove_entry < Q : ?Sized > ( & mut self , key : & Q ) -> Option < ( K , V ) >
11281121 where
1129- K : Borrow < Q > + Ord ,
1130- Q : Ord ,
1122+ K : Comparable < Q > + Ord ,
11311123 {
11321124 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
11331125 let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
@@ -1260,7 +1252,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12601252 pub fn range < T : ?Sized , R > ( & self , range : R ) -> Range < ' _ , K , V >
12611253 where
12621254 T : Ord ,
1263- K : Borrow < T > + Ord ,
1255+ K : Comparable < T > ,
12641256 R : RangeBounds < T > ,
12651257 {
12661258 if let Some ( root) = & self . root {
@@ -1300,7 +1292,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
13001292 pub fn range_mut < T : ?Sized , R > ( & mut self , range : R ) -> RangeMut < ' _ , K , V >
13011293 where
13021294 T : Ord ,
1303- K : Borrow < T > + Ord ,
1295+ K : Comparable < T > ,
13041296 R : RangeBounds < T > ,
13051297 {
13061298 if let Some ( root) = & mut self . root {
@@ -1388,9 +1380,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
13881380 /// assert_eq!(b[&41], "e");
13891381 /// ```
13901382 #[ stable( feature = "btree_split_off" , since = "1.11.0" ) ]
1391- pub fn split_off < Q : ?Sized + Ord > ( & mut self , key : & Q ) -> Self
1383+ pub fn split_off < Q : ?Sized > ( & mut self , key : & Q ) -> Self
13921384 where
1393- K : Borrow < Q > + Ord ,
1385+ K : Comparable < Q > + Ord ,
13941386 A : Clone ,
13951387 {
13961388 if self . is_empty ( ) {
@@ -2440,8 +2432,7 @@ impl<K: Debug, V: Debug, A: Allocator + Clone> Debug for BTreeMap<K, V, A> {
24402432#[ stable( feature = "rust1" , since = "1.0.0" ) ]
24412433impl < K , Q : ?Sized , V , A : Allocator + Clone > Index < & Q > for BTreeMap < K , V , A >
24422434where
2443- K : Borrow < Q > + Ord ,
2444- Q : Ord ,
2435+ K : Comparable < Q > + Ord ,
24452436{
24462437 type Output = V ;
24472438
@@ -2694,8 +2685,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26942685 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
26952686 pub fn lower_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
26962687 where
2697- K : Borrow < Q > + Ord ,
2698- Q : Ord ,
2688+ K : Comparable < Q > + Ord ,
26992689 {
27002690 let root_node = match self . root . as_ref ( ) {
27012691 None => return Cursor { current : None , root : None } ,
@@ -2747,8 +2737,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
27472737 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
27482738 pub fn lower_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
27492739 where
2750- K : Borrow < Q > + Ord ,
2751- Q : Ord ,
2740+ K : Comparable < Q > + Ord ,
27522741 {
27532742 let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
27542743 let root_node = match root. as_mut ( ) {
@@ -2817,8 +2806,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
28172806 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
28182807 pub fn upper_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
28192808 where
2820- K : Borrow < Q > + Ord ,
2821- Q : Ord ,
2809+ K : Comparable < Q > + Ord ,
28222810 {
28232811 let root_node = match self . root . as_ref ( ) {
28242812 None => return Cursor { current : None , root : None } ,
@@ -2870,8 +2858,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
28702858 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
28712859 pub fn upper_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
28722860 where
2873- K : Borrow < Q > + Ord ,
2874- Q : Ord ,
2861+ K : Comparable < Q > + Ord ,
28752862 {
28762863 let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
28772864 let root_node = match root. as_mut ( ) {
0 commit comments