1
- use core:: borrow:: Borrow ;
2
- use core:: cmp:: Ordering ;
1
+ use core:: cmp:: { Comparable , Ordering } ;
3
2
use core:: error:: Error ;
4
3
use core:: fmt:: { self , Debug } ;
5
4
use core:: hash:: { Hash , Hasher } ;
@@ -316,8 +315,7 @@ impl<K, A: Allocator + Clone> BTreeMap<K, SetValZST, A> {
316
315
317
316
pub ( super ) fn get_or_insert_with < Q : ?Sized , F > ( & mut self , q : & Q , f : F ) -> & K
318
317
where
319
- K : Borrow < Q > + Ord ,
320
- Q : Ord ,
318
+ K : Comparable < Q > + Ord ,
321
319
F : FnOnce ( & Q ) -> K ,
322
320
{
323
321
let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
@@ -327,7 +325,7 @@ impl<K, A: Allocator + Clone> BTreeMap<K, SetValZST, A> {
327
325
Found ( handle) => handle. into_kv_mut ( ) . 0 ,
328
326
GoDown ( handle) => {
329
327
let key = f ( q) ;
330
- assert ! ( * key. borrow ( ) == * q , "new value is not equal" ) ;
328
+ assert ! ( key. equivalent ( q ) , "new value is not equal" ) ;
331
329
VacantEntry {
332
330
key,
333
331
handle : Some ( handle) ,
@@ -694,8 +692,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
694
692
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
695
693
pub fn get < Q : ?Sized > ( & self , key : & Q ) -> Option < & V >
696
694
where
697
- K : Borrow < Q > + Ord ,
698
- Q : Ord ,
695
+ K : Comparable < Q > + Ord ,
699
696
{
700
697
let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
701
698
match root_node. search_tree ( key) {
@@ -760,8 +757,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
760
757
#[ stable( feature = "map_get_key_value" , since = "1.40.0" ) ]
761
758
pub fn get_key_value < Q : ?Sized > ( & self , k : & Q ) -> Option < ( & K , & V ) >
762
759
where
763
- K : Borrow < Q > + Ord ,
764
- Q : Ord ,
760
+ K : Comparable < Q > + Ord ,
765
761
{
766
762
let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
767
763
match root_node. search_tree ( k) {
@@ -956,8 +952,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
956
952
#[ cfg_attr( not( test) , rustc_diagnostic_item = "btreemap_contains_key" ) ]
957
953
pub fn contains_key < Q : ?Sized > ( & self , key : & Q ) -> bool
958
954
where
959
- K : Borrow < Q > + Ord ,
960
- Q : Ord ,
955
+ K : Comparable < Q > + Ord ,
961
956
{
962
957
self . get ( key) . is_some ( )
963
958
}
@@ -983,8 +978,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
983
978
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
984
979
pub fn get_mut < Q : ?Sized > ( & mut self , key : & Q ) -> Option < & mut V >
985
980
where
986
- K : Borrow < Q > + Ord ,
987
- Q : Ord ,
981
+ K : Comparable < Q > + Ord ,
988
982
{
989
983
let root_node = self . root . as_mut ( ) ?. borrow_mut ( ) ;
990
984
match root_node. search_tree ( key) {
@@ -1085,8 +1079,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1085
1079
#[ rustc_confusables( "delete" , "take" ) ]
1086
1080
pub fn remove < Q : ?Sized > ( & mut self , key : & Q ) -> Option < V >
1087
1081
where
1088
- K : Borrow < Q > + Ord ,
1089
- Q : Ord ,
1082
+ K : Comparable < Q > + Ord ,
1090
1083
{
1091
1084
self . remove_entry ( key) . map ( |( _, v) | v)
1092
1085
}
@@ -1110,8 +1103,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1110
1103
#[ stable( feature = "btreemap_remove_entry" , since = "1.45.0" ) ]
1111
1104
pub fn remove_entry < Q : ?Sized > ( & mut self , key : & Q ) -> Option < ( K , V ) >
1112
1105
where
1113
- K : Borrow < Q > + Ord ,
1114
- Q : Ord ,
1106
+ K : Comparable < Q > + Ord ,
1115
1107
{
1116
1108
let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
1117
1109
let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
@@ -1244,7 +1236,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1244
1236
pub fn range < T : ?Sized , R > ( & self , range : R ) -> Range < ' _ , K , V >
1245
1237
where
1246
1238
T : Ord ,
1247
- K : Borrow < T > + Ord ,
1239
+ K : Comparable < T > ,
1248
1240
R : RangeBounds < T > ,
1249
1241
{
1250
1242
if let Some ( root) = & self . root {
@@ -1284,7 +1276,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1284
1276
pub fn range_mut < T : ?Sized , R > ( & mut self , range : R ) -> RangeMut < ' _ , K , V >
1285
1277
where
1286
1278
T : Ord ,
1287
- K : Borrow < T > + Ord ,
1279
+ K : Comparable < T > ,
1288
1280
R : RangeBounds < T > ,
1289
1281
{
1290
1282
if let Some ( root) = & mut self . root {
@@ -1372,9 +1364,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
1372
1364
/// assert_eq!(b[&41], "e");
1373
1365
/// ```
1374
1366
#[ stable( feature = "btree_split_off" , since = "1.11.0" ) ]
1375
- pub fn split_off < Q : ?Sized + Ord > ( & mut self , key : & Q ) -> Self
1367
+ pub fn split_off < Q : ?Sized > ( & mut self , key : & Q ) -> Self
1376
1368
where
1377
- K : Borrow < Q > + Ord ,
1369
+ K : Comparable < Q > + Ord ,
1378
1370
A : Clone ,
1379
1371
{
1380
1372
if self . is_empty ( ) {
@@ -2424,8 +2416,7 @@ impl<K: Debug, V: Debug, A: Allocator + Clone> Debug for BTreeMap<K, V, A> {
2424
2416
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2425
2417
impl < K , Q : ?Sized , V , A : Allocator + Clone > Index < & Q > for BTreeMap < K , V , A >
2426
2418
where
2427
- K : Borrow < Q > + Ord ,
2428
- Q : Ord ,
2419
+ K : Comparable < Q > + Ord ,
2429
2420
{
2430
2421
type Output = V ;
2431
2422
@@ -2678,8 +2669,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
2678
2669
#[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2679
2670
pub fn lower_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
2680
2671
where
2681
- K : Borrow < Q > + Ord ,
2682
- Q : Ord ,
2672
+ K : Comparable < Q > + Ord ,
2683
2673
{
2684
2674
let root_node = match self . root . as_ref ( ) {
2685
2675
None => return Cursor { current : None , root : None } ,
@@ -2731,8 +2721,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
2731
2721
#[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2732
2722
pub fn lower_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
2733
2723
where
2734
- K : Borrow < Q > + Ord ,
2735
- Q : Ord ,
2724
+ K : Comparable < Q > + Ord ,
2736
2725
{
2737
2726
let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
2738
2727
let root_node = match root. as_mut ( ) {
@@ -2801,8 +2790,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
2801
2790
#[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2802
2791
pub fn upper_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
2803
2792
where
2804
- K : Borrow < Q > + Ord ,
2805
- Q : Ord ,
2793
+ K : Comparable < Q > + Ord ,
2806
2794
{
2807
2795
let root_node = match self . root . as_ref ( ) {
2808
2796
None => return Cursor { current : None , root : None } ,
@@ -2854,8 +2842,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
2854
2842
#[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2855
2843
pub fn upper_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
2856
2844
where
2857
- K : Borrow < Q > + Ord ,
2858
- Q : Ord ,
2845
+ K : Comparable < Q > + Ord ,
2859
2846
{
2860
2847
let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
2861
2848
let root_node = match root. as_mut ( ) {
0 commit comments