Skip to content

Commit acdf367

Browse files
authored
Rollup merge of #137829 - cramertj:stabilize-split-off, r=jhpratt
Stabilize [T]::split_off... methods This was previously known as the slice_take feature. Closes #62280
2 parents b4ae140 + a8bff87 commit acdf367

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

library/core/src/slice/mod.rs

+7-27
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub use raw::{from_raw_parts, from_raw_parts_mut};
7878

7979
/// Calculates the direction and split point of a one-sided range.
8080
///
81-
/// This is a helper function for `take` and `take_mut` that returns
81+
/// This is a helper function for `split_off` and `split_off_mut` that returns
8282
/// the direction of the split (front or back) as well as the index at
8383
/// which to split. Returns `None` if the split index would overflow.
8484
#[inline]
@@ -4313,8 +4313,6 @@ impl<T> [T] {
43134313
/// Splitting off the first three elements of a slice:
43144314
///
43154315
/// ```
4316-
/// #![feature(slice_take)]
4317-
///
43184316
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
43194317
/// let mut first_three = slice.split_off(..3).unwrap();
43204318
///
@@ -4325,8 +4323,6 @@ impl<T> [T] {
43254323
/// Splitting off the last two elements of a slice:
43264324
///
43274325
/// ```
4328-
/// #![feature(slice_take)]
4329-
///
43304326
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
43314327
/// let mut tail = slice.split_off(2..).unwrap();
43324328
///
@@ -4337,8 +4333,6 @@ impl<T> [T] {
43374333
/// Getting `None` when `range` is out of bounds:
43384334
///
43394335
/// ```
4340-
/// #![feature(slice_take)]
4341-
///
43424336
/// let mut slice: &[_] = &['a', 'b', 'c', 'd'];
43434337
///
43444338
/// assert_eq!(None, slice.split_off(5..));
@@ -4349,7 +4343,7 @@ impl<T> [T] {
43494343
/// ```
43504344
#[inline]
43514345
#[must_use = "method does not modify the slice if the range is out of bounds"]
4352-
#[unstable(feature = "slice_take", issue = "62280")]
4346+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
43534347
pub fn split_off<'a, R: OneSidedRange<usize>>(
43544348
self: &mut &'a Self,
43554349
range: R,
@@ -4385,8 +4379,6 @@ impl<T> [T] {
43854379
/// Splitting off the first three elements of a slice:
43864380
///
43874381
/// ```
4388-
/// #![feature(slice_take)]
4389-
///
43904382
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
43914383
/// let mut first_three = slice.split_off_mut(..3).unwrap();
43924384
///
@@ -4397,8 +4389,6 @@ impl<T> [T] {
43974389
/// Taking the last two elements of a slice:
43984390
///
43994391
/// ```
4400-
/// #![feature(slice_take)]
4401-
///
44024392
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
44034393
/// let mut tail = slice.split_off_mut(2..).unwrap();
44044394
///
@@ -4409,8 +4399,6 @@ impl<T> [T] {
44094399
/// Getting `None` when `range` is out of bounds:
44104400
///
44114401
/// ```
4412-
/// #![feature(slice_take)]
4413-
///
44144402
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c', 'd'];
44154403
///
44164404
/// assert_eq!(None, slice.split_off_mut(5..));
@@ -4421,7 +4409,7 @@ impl<T> [T] {
44214409
/// ```
44224410
#[inline]
44234411
#[must_use = "method does not modify the slice if the range is out of bounds"]
4424-
#[unstable(feature = "slice_take", issue = "62280")]
4412+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
44254413
pub fn split_off_mut<'a, R: OneSidedRange<usize>>(
44264414
self: &mut &'a mut Self,
44274415
range: R,
@@ -4451,16 +4439,14 @@ impl<T> [T] {
44514439
/// # Examples
44524440
///
44534441
/// ```
4454-
/// #![feature(slice_take)]
4455-
///
44564442
/// let mut slice: &[_] = &['a', 'b', 'c'];
44574443
/// let first = slice.split_off_first().unwrap();
44584444
///
44594445
/// assert_eq!(slice, &['b', 'c']);
44604446
/// assert_eq!(first, &'a');
44614447
/// ```
44624448
#[inline]
4463-
#[unstable(feature = "slice_take", issue = "62280")]
4449+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
44644450
pub fn split_off_first<'a>(self: &mut &'a Self) -> Option<&'a T> {
44654451
let (first, rem) = self.split_first()?;
44664452
*self = rem;
@@ -4475,8 +4461,6 @@ impl<T> [T] {
44754461
/// # Examples
44764462
///
44774463
/// ```
4478-
/// #![feature(slice_take)]
4479-
///
44804464
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
44814465
/// let first = slice.split_off_first_mut().unwrap();
44824466
/// *first = 'd';
@@ -4485,7 +4469,7 @@ impl<T> [T] {
44854469
/// assert_eq!(first, &'d');
44864470
/// ```
44874471
#[inline]
4488-
#[unstable(feature = "slice_take", issue = "62280")]
4472+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
44894473
pub fn split_off_first_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
44904474
let (first, rem) = mem::take(self).split_first_mut()?;
44914475
*self = rem;
@@ -4500,16 +4484,14 @@ impl<T> [T] {
45004484
/// # Examples
45014485
///
45024486
/// ```
4503-
/// #![feature(slice_take)]
4504-
///
45054487
/// let mut slice: &[_] = &['a', 'b', 'c'];
45064488
/// let last = slice.split_off_last().unwrap();
45074489
///
45084490
/// assert_eq!(slice, &['a', 'b']);
45094491
/// assert_eq!(last, &'c');
45104492
/// ```
45114493
#[inline]
4512-
#[unstable(feature = "slice_take", issue = "62280")]
4494+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
45134495
pub fn split_off_last<'a>(self: &mut &'a Self) -> Option<&'a T> {
45144496
let (last, rem) = self.split_last()?;
45154497
*self = rem;
@@ -4524,8 +4506,6 @@ impl<T> [T] {
45244506
/// # Examples
45254507
///
45264508
/// ```
4527-
/// #![feature(slice_take)]
4528-
///
45294509
/// let mut slice: &mut [_] = &mut ['a', 'b', 'c'];
45304510
/// let last = slice.split_off_last_mut().unwrap();
45314511
/// *last = 'd';
@@ -4534,7 +4514,7 @@ impl<T> [T] {
45344514
/// assert_eq!(last, &'d');
45354515
/// ```
45364516
#[inline]
4537-
#[unstable(feature = "slice_take", issue = "62280")]
4517+
#[stable(feature = "slice_take", since = "CURRENT_RUSTC_VERSION")]
45384518
pub fn split_off_last_mut<'a>(self: &mut &'a mut Self) -> Option<&'a mut T> {
45394519
let (last, rem) = mem::take(self).split_last_mut()?;
45404520
*self = rem;

library/coretests/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#![feature(slice_internals)]
7474
#![feature(slice_partition_dedup)]
7575
#![feature(slice_split_once)]
76-
#![feature(slice_take)]
7776
#![feature(split_array)]
7877
#![feature(split_as_slice)]
7978
#![feature(std_internals)]

0 commit comments

Comments
 (0)