@@ -222,14 +222,10 @@ where
222222#[ stable( feature = "rust1" , since = "1.0.0" ) ]
223223impl < K : Clone , V : Clone , A : Allocator + Clone > Clone for BTreeMap < K , V , A > {
224224 fn clone ( & self ) -> BTreeMap < K , V , A > {
225- fn clone_subtree < ' a , K : Clone , V : Clone , A : Allocator + Clone > (
225+ fn clone_subtree < ' a , K : Clone + ' a , V : Clone + ' a , A : Allocator + Clone > (
226226 node : NodeRef < marker:: Immut < ' a > , K , V , marker:: LeafOrInternal > ,
227227 alloc : A ,
228- ) -> BTreeMap < K , V , A >
229- where
230- K : ' a ,
231- V : ' a ,
232- {
228+ ) -> BTreeMap < K , V , A > {
233229 match node. force ( ) {
234230 Leaf ( leaf) => {
235231 let mut out_tree = BTreeMap {
@@ -330,11 +326,13 @@ impl<K, A: Allocator + Clone> BTreeMap<K, SetValZST, A> {
330326 }
331327 }
332328
333- pub ( super ) fn get_or_insert_with < Q : ?Sized , F > ( & mut self , q : & Q , f : F ) -> & K
329+ pub ( super ) fn get_or_insert_with < Q : ?Sized + Ord > (
330+ & mut self ,
331+ q : & Q ,
332+ f : impl FnOnce ( & Q ) -> K ,
333+ ) -> & K
334334 where
335335 K : Borrow < Q > + Ord ,
336- Q : Ord ,
337- F : FnOnce ( & Q ) -> K ,
338336 {
339337 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
340338 let root_node =
@@ -708,10 +706,10 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
708706 /// assert_eq!(map.get(&2), None);
709707 /// ```
710708 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
711- pub fn get < Q : ? Sized > ( & self , key : & Q ) -> Option < & V >
709+ pub fn get < Q > ( & self , key : & Q ) -> Option < & V >
712710 where
711+ Q : ?Sized + Ord ,
713712 K : Borrow < Q > + Ord ,
714- Q : Ord ,
715713 {
716714 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
717715 match root_node. search_tree ( key) {
@@ -774,10 +772,10 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
774772 /// assert_eq!(map.get_key_value(&p), None);
775773 /// ```
776774 #[ stable( feature = "map_get_key_value" , since = "1.40.0" ) ]
777- pub fn get_key_value < Q : ? Sized > ( & self , k : & Q ) -> Option < ( & K , & V ) >
775+ pub fn get_key_value < Q > ( & self , k : & Q ) -> Option < ( & K , & V ) >
778776 where
777+ Q : ?Sized + Ord ,
779778 K : Borrow < Q > + Ord ,
780- Q : Ord ,
781779 {
782780 let root_node = self . root . as_ref ( ) ?. reborrow ( ) ;
783781 match root_node. search_tree ( k) {
@@ -970,10 +968,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
970968 /// ```
971969 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
972970 #[ cfg_attr( not( test) , rustc_diagnostic_item = "btreemap_contains_key" ) ]
973- pub fn contains_key < Q : ?Sized > ( & self , key : & Q ) -> bool
971+ pub fn contains_key < Q : ?Sized + Ord > ( & self , key : & Q ) -> bool
974972 where
975973 K : Borrow < Q > + Ord ,
976- Q : Ord ,
977974 {
978975 self . get ( key) . is_some ( )
979976 }
@@ -997,10 +994,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
997994 /// ```
998995 // See `get` for implementation notes, this is basically a copy-paste with mut's added
999996 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1000- pub fn get_mut < Q : ?Sized > ( & mut self , key : & Q ) -> Option < & mut V >
997+ pub fn get_mut < Q : ?Sized + Ord > ( & mut self , key : & Q ) -> Option < & mut V >
1001998 where
1002999 K : Borrow < Q > + Ord ,
1003- Q : Ord ,
10041000 {
10051001 let root_node = self . root . as_mut ( ) ?. borrow_mut ( ) ;
10061002 match root_node. search_tree ( key) {
@@ -1099,10 +1095,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
10991095 /// ```
11001096 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
11011097 #[ rustc_confusables( "delete" , "take" ) ]
1102- pub fn remove < Q : ?Sized > ( & mut self , key : & Q ) -> Option < V >
1098+ pub fn remove < Q : ?Sized + Ord > ( & mut self , key : & Q ) -> Option < V >
11031099 where
11041100 K : Borrow < Q > + Ord ,
1105- Q : Ord ,
11061101 {
11071102 self . remove_entry ( key) . map ( |( _, v) | v)
11081103 }
@@ -1124,10 +1119,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
11241119 /// assert_eq!(map.remove_entry(&1), None);
11251120 /// ```
11261121 #[ stable( feature = "btreemap_remove_entry" , since = "1.45.0" ) ]
1127- pub fn remove_entry < Q : ?Sized > ( & mut self , key : & Q ) -> Option < ( K , V ) >
1122+ pub fn remove_entry < Q : ?Sized + Ord > ( & mut self , key : & Q ) -> Option < ( K , V ) >
11281123 where
11291124 K : Borrow < Q > + Ord ,
1130- Q : Ord ,
11311125 {
11321126 let ( map, dormant_map) = DormantMutRef :: new ( self ) ;
11331127 let root_node = map. root . as_mut ( ) ?. borrow_mut ( ) ;
@@ -1257,9 +1251,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12571251 /// assert_eq!(Some((&5, &"b")), map.range(4..).next());
12581252 /// ```
12591253 #[ stable( feature = "btree_range" , since = "1.17.0" ) ]
1260- pub fn range < T : ?Sized , R > ( & self , range : R ) -> Range < ' _ , K , V >
1254+ pub fn range < T : ?Sized + Ord , R > ( & self , range : R ) -> Range < ' _ , K , V >
12611255 where
1262- T : Ord ,
12631256 K : Borrow < T > + Ord ,
12641257 R : RangeBounds < T > ,
12651258 {
@@ -1297,9 +1290,8 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
12971290 /// }
12981291 /// ```
12991292 #[ stable( feature = "btree_range" , since = "1.17.0" ) ]
1300- pub fn range_mut < T : ?Sized , R > ( & mut self , range : R ) -> RangeMut < ' _ , K , V >
1293+ pub fn range_mut < T : ?Sized + Ord , R > ( & mut self , range : R ) -> RangeMut < ' _ , K , V >
13011294 where
1302- T : Ord ,
13031295 K : Borrow < T > + Ord ,
13041296 R : RangeBounds < T > ,
13051297 {
@@ -2691,10 +2683,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
26912683 /// assert_eq!(cursor.peek_next(), Some((&1, &"a")));
26922684 /// ```
26932685 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2694- pub fn lower_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
2686+ pub fn lower_bound < Q : ?Sized + Ord > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
26952687 where
26962688 K : Borrow < Q > + Ord ,
2697- Q : Ord ,
26982689 {
26992690 let root_node = match self . root . as_ref ( ) {
27002691 None => return Cursor { current : None , root : None } ,
@@ -2744,10 +2735,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
27442735 /// assert_eq!(cursor.peek_next(), Some((&1, &mut "a")));
27452736 /// ```
27462737 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2747- pub fn lower_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
2738+ pub fn lower_bound_mut < Q : ?Sized + Ord > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
27482739 where
27492740 K : Borrow < Q > + Ord ,
2750- Q : Ord ,
27512741 {
27522742 let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
27532743 let root_node = match root. as_mut ( ) {
@@ -2814,10 +2804,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
28142804 /// assert_eq!(cursor.peek_next(), None);
28152805 /// ```
28162806 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2817- pub fn upper_bound < Q : ?Sized > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
2807+ pub fn upper_bound < Q : ?Sized + Ord > ( & self , bound : Bound < & Q > ) -> Cursor < ' _ , K , V >
28182808 where
28192809 K : Borrow < Q > + Ord ,
2820- Q : Ord ,
28212810 {
28222811 let root_node = match self . root . as_ref ( ) {
28232812 None => return Cursor { current : None , root : None } ,
@@ -2867,10 +2856,9 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
28672856 /// assert_eq!(cursor.peek_next(), None);
28682857 /// ```
28692858 #[ unstable( feature = "btree_cursors" , issue = "107540" ) ]
2870- pub fn upper_bound_mut < Q : ?Sized > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
2859+ pub fn upper_bound_mut < Q : ?Sized + Ord > ( & mut self , bound : Bound < & Q > ) -> CursorMut < ' _ , K , V , A >
28712860 where
28722861 K : Borrow < Q > + Ord ,
2873- Q : Ord ,
28742862 {
28752863 let ( root, dormant_root) = DormantMutRef :: new ( & mut self . root ) ;
28762864 let root_node = match root. as_mut ( ) {
0 commit comments