@@ -2034,6 +2034,50 @@ impl<T> [T] {
20342034 sort:: quicksort ( self , |a, b| f ( a) . lt ( & f ( b) ) ) ;
20352035 }
20362036
2037+ /// Reorder the slice such that the element at `index` is at its final sorted position.
2038+ #[ unstable( feature = "slice_partition_at_index" , issue = "55300" ) ]
2039+ #[ rustc_deprecated( since = "1.49.0" , reason = "use the select_nth_unstable() instead" ) ]
2040+ #[ inline]
2041+ pub fn partition_at_index ( & mut self , index : usize ) -> ( & mut [ T ] , & mut T , & mut [ T ] )
2042+ where
2043+ T : Ord ,
2044+ {
2045+ self . select_nth_unstable ( index)
2046+ }
2047+
2048+ /// Reorder the slice with a comparator function such that the element at `index` is at its
2049+ /// final sorted position.
2050+ #[ unstable( feature = "slice_partition_at_index" , issue = "55300" ) ]
2051+ #[ rustc_deprecated( since = "1.49.0" , reason = "use select_nth_unstable_by() instead" ) ]
2052+ #[ inline]
2053+ pub fn partition_at_index_by < F > (
2054+ & mut self ,
2055+ index : usize ,
2056+ compare : F ,
2057+ ) -> ( & mut [ T ] , & mut T , & mut [ T ] )
2058+ where
2059+ F : FnMut ( & T , & T ) -> Ordering ,
2060+ {
2061+ self . select_nth_unstable_by ( index, compare)
2062+ }
2063+
2064+ /// Reorder the slice with a key extraction function such that the element at `index` is at its
2065+ /// final sorted position.
2066+ #[ unstable( feature = "slice_partition_at_index" , issue = "55300" ) ]
2067+ #[ rustc_deprecated( since = "1.49.0" , reason = "use the select_nth_unstable_by_key() instead" ) ]
2068+ #[ inline]
2069+ pub fn partition_at_index_by_key < K , F > (
2070+ & mut self ,
2071+ index : usize ,
2072+ f : F ,
2073+ ) -> ( & mut [ T ] , & mut T , & mut [ T ] )
2074+ where
2075+ F : FnMut ( & T ) -> K ,
2076+ K : Ord ,
2077+ {
2078+ self . select_nth_unstable_by_key ( index, f)
2079+ }
2080+
20372081 /// Reorder the slice such that the element at `index` is at its final sorted position.
20382082 ///
20392083 /// This reordering has the additional property that any value at position `i < index` will be
@@ -2058,12 +2102,10 @@ impl<T> [T] {
20582102 /// # Examples
20592103 ///
20602104 /// ```
2061- /// #![feature(slice_partition_at_index)]
2062- ///
20632105 /// let mut v = [-5i32, 4, 1, -3, 2];
20642106 ///
20652107 /// // Find the median
2066- /// v.partition_at_index (2);
2108+ /// v.select_nth_unstable (2);
20672109 ///
20682110 /// // We are only guaranteed the slice will be one of the following, based on the way we sort
20692111 /// // about the specified index.
@@ -2072,9 +2114,9 @@ impl<T> [T] {
20722114 /// v == [-3, -5, 1, 4, 2] ||
20732115 /// v == [-5, -3, 1, 4, 2]);
20742116 /// ```
2075- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2117+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
20762118 #[ inline]
2077- pub fn partition_at_index ( & mut self , index : usize ) -> ( & mut [ T ] , & mut T , & mut [ T ] )
2119+ pub fn select_nth_unstable ( & mut self , index : usize ) -> ( & mut [ T ] , & mut T , & mut [ T ] )
20782120 where
20792121 T : Ord ,
20802122 {
@@ -2108,12 +2150,10 @@ impl<T> [T] {
21082150 /// # Examples
21092151 ///
21102152 /// ```
2111- /// #![feature(slice_partition_at_index)]
2112- ///
21132153 /// let mut v = [-5i32, 4, 1, -3, 2];
21142154 ///
21152155 /// // Find the median as if the slice were sorted in descending order.
2116- /// v.partition_at_index_by (2, |a, b| b.cmp(a));
2156+ /// v.select_nth_unstable_by (2, |a, b| b.cmp(a));
21172157 ///
21182158 /// // We are only guaranteed the slice will be one of the following, based on the way we sort
21192159 /// // about the specified index.
@@ -2122,9 +2162,9 @@ impl<T> [T] {
21222162 /// v == [4, 2, 1, -5, -3] ||
21232163 /// v == [4, 2, 1, -3, -5]);
21242164 /// ```
2125- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2165+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
21262166 #[ inline]
2127- pub fn partition_at_index_by < F > (
2167+ pub fn select_nth_unstable_by < F > (
21282168 & mut self ,
21292169 index : usize ,
21302170 mut compare : F ,
@@ -2162,12 +2202,10 @@ impl<T> [T] {
21622202 /// # Examples
21632203 ///
21642204 /// ```
2165- /// #![feature(slice_partition_at_index)]
2166- ///
21672205 /// let mut v = [-5i32, 4, 1, -3, 2];
21682206 ///
21692207 /// // Return the median as if the array were sorted according to absolute value.
2170- /// v.partition_at_index_by_key (2, |a| a.abs());
2208+ /// v.select_nth_unstable_by_key (2, |a| a.abs());
21712209 ///
21722210 /// // We are only guaranteed the slice will be one of the following, based on the way we sort
21732211 /// // about the specified index.
@@ -2176,9 +2214,9 @@ impl<T> [T] {
21762214 /// v == [2, 1, -3, 4, -5] ||
21772215 /// v == [2, 1, -3, -5, 4]);
21782216 /// ```
2179- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2217+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
21802218 #[ inline]
2181- pub fn partition_at_index_by_key < K , F > (
2219+ pub fn select_nth_unstable_by_key < K , F > (
21822220 & mut self ,
21832221 index : usize ,
21842222 mut f : F ,
0 commit comments