@@ -2034,6 +2034,50 @@ impl<T> [T] {
2034
2034
sort:: quicksort ( self , |a, b| f ( a) . lt ( & f ( b) ) ) ;
2035
2035
}
2036
2036
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
+
2037
2081
/// Reorder the slice such that the element at `index` is at its final sorted position.
2038
2082
///
2039
2083
/// This reordering has the additional property that any value at position `i < index` will be
@@ -2058,12 +2102,10 @@ impl<T> [T] {
2058
2102
/// # Examples
2059
2103
///
2060
2104
/// ```
2061
- /// #![feature(slice_partition_at_index)]
2062
- ///
2063
2105
/// let mut v = [-5i32, 4, 1, -3, 2];
2064
2106
///
2065
2107
/// // Find the median
2066
- /// v.partition_at_index (2);
2108
+ /// v.select_nth_unstable (2);
2067
2109
///
2068
2110
/// // We are only guaranteed the slice will be one of the following, based on the way we sort
2069
2111
/// // about the specified index.
@@ -2072,9 +2114,9 @@ impl<T> [T] {
2072
2114
/// v == [-3, -5, 1, 4, 2] ||
2073
2115
/// v == [-5, -3, 1, 4, 2]);
2074
2116
/// ```
2075
- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2117
+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
2076
2118
#[ 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 ] )
2078
2120
where
2079
2121
T : Ord ,
2080
2122
{
@@ -2108,12 +2150,10 @@ impl<T> [T] {
2108
2150
/// # Examples
2109
2151
///
2110
2152
/// ```
2111
- /// #![feature(slice_partition_at_index)]
2112
- ///
2113
2153
/// let mut v = [-5i32, 4, 1, -3, 2];
2114
2154
///
2115
2155
/// // 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));
2117
2157
///
2118
2158
/// // We are only guaranteed the slice will be one of the following, based on the way we sort
2119
2159
/// // about the specified index.
@@ -2122,9 +2162,9 @@ impl<T> [T] {
2122
2162
/// v == [4, 2, 1, -5, -3] ||
2123
2163
/// v == [4, 2, 1, -3, -5]);
2124
2164
/// ```
2125
- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2165
+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
2126
2166
#[ inline]
2127
- pub fn partition_at_index_by < F > (
2167
+ pub fn select_nth_unstable_by < F > (
2128
2168
& mut self ,
2129
2169
index : usize ,
2130
2170
mut compare : F ,
@@ -2162,12 +2202,10 @@ impl<T> [T] {
2162
2202
/// # Examples
2163
2203
///
2164
2204
/// ```
2165
- /// #![feature(slice_partition_at_index)]
2166
- ///
2167
2205
/// let mut v = [-5i32, 4, 1, -3, 2];
2168
2206
///
2169
2207
/// // 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());
2171
2209
///
2172
2210
/// // We are only guaranteed the slice will be one of the following, based on the way we sort
2173
2211
/// // about the specified index.
@@ -2176,9 +2214,9 @@ impl<T> [T] {
2176
2214
/// v == [2, 1, -3, 4, -5] ||
2177
2215
/// v == [2, 1, -3, -5, 4]);
2178
2216
/// ```
2179
- #[ unstable ( feature = "slice_partition_at_index " , issue = "55300 " ) ]
2217
+ #[ stable ( feature = "slice_select_nth_unstable " , since = "1.49.0 " ) ]
2180
2218
#[ inline]
2181
- pub fn partition_at_index_by_key < K , F > (
2219
+ pub fn select_nth_unstable_by_key < K , F > (
2182
2220
& mut self ,
2183
2221
index : usize ,
2184
2222
mut f : F ,
0 commit comments