Stabilize slice_first_last_chunk
This stabilizes all methods under `slice_first_last_chunk`. Additionally, it const stabilizes the non-mut functions and moves the `_mut` functions under `const_slice_first_last_chunk`. These are blocked on `const_mut_refs`. As part of this change, `slice_split_at_unchecked` was marked const-stable for internal use (but not fully stable).
This commit is contained in:
parent
01337bf1fd
commit
500d6f6479
@ -16,7 +16,6 @@
|
||||
#![feature(min_specialization)]
|
||||
#![feature(never_type)]
|
||||
#![feature(ptr_sub_ptr)]
|
||||
#![feature(slice_first_last_chunk)]
|
||||
#![cfg_attr(test, feature(test))]
|
||||
#![allow(rustc::internal)]
|
||||
#![deny(rustc::untranslatable_diagnostic)]
|
||||
|
@ -327,8 +327,6 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let u = [10, 40, 30];
|
||||
/// assert_eq!(Some(&[10, 40]), u.first_chunk::<2>());
|
||||
///
|
||||
@ -338,9 +336,9 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
/// let w: &[i32] = &[];
|
||||
/// assert_eq!(Some(&[]), w.first_chunk::<0>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn first_chunk<const N: usize>(&self) -> Option<&[T; N]> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -358,8 +356,6 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &mut [0, 1, 2];
|
||||
///
|
||||
/// if let Some(first) = x.first_chunk_mut::<2>() {
|
||||
@ -370,9 +366,9 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
///
|
||||
/// assert_eq!(None, x.first_chunk_mut::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
|
||||
pub const fn first_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -391,8 +387,6 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &[0, 1, 2];
|
||||
///
|
||||
/// if let Some((first, elements)) = x.split_first_chunk::<2>() {
|
||||
@ -402,9 +396,9 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
///
|
||||
/// assert_eq!(None, x.split_first_chunk::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn split_first_chunk<const N: usize>(&self) -> Option<(&[T; N], &[T])> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -426,8 +420,6 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &mut [0, 1, 2];
|
||||
///
|
||||
/// if let Some((first, elements)) = x.split_first_chunk_mut::<2>() {
|
||||
@ -439,9 +431,9 @@ pub const fn last_mut(&mut self) -> Option<&mut T> {
|
||||
///
|
||||
/// assert_eq!(None, x.split_first_chunk_mut::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
|
||||
pub const fn split_first_chunk_mut<const N: usize>(
|
||||
&mut self,
|
||||
) -> Option<(&mut [T; N], &mut [T])> {
|
||||
@ -465,8 +457,6 @@ pub const fn split_first_chunk_mut<const N: usize>(
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &[0, 1, 2];
|
||||
///
|
||||
/// if let Some((elements, last)) = x.split_last_chunk::<2>() {
|
||||
@ -476,9 +466,9 @@ pub const fn split_first_chunk_mut<const N: usize>(
|
||||
///
|
||||
/// assert_eq!(None, x.split_last_chunk::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
pub const fn split_last_chunk<const N: usize>(&self) -> Option<(&[T], &[T; N])> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -500,8 +490,6 @@ pub const fn split_first_chunk_mut<const N: usize>(
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &mut [0, 1, 2];
|
||||
///
|
||||
/// if let Some((elements, last)) = x.split_last_chunk_mut::<2>() {
|
||||
@ -513,9 +501,9 @@ pub const fn split_first_chunk_mut<const N: usize>(
|
||||
///
|
||||
/// assert_eq!(None, x.split_last_chunk_mut::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
|
||||
pub const fn split_last_chunk_mut<const N: usize>(
|
||||
&mut self,
|
||||
) -> Option<(&mut [T], &mut [T; N])> {
|
||||
@ -539,8 +527,6 @@ pub const fn split_last_chunk_mut<const N: usize>(
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let u = [10, 40, 30];
|
||||
/// assert_eq!(Some(&[40, 30]), u.last_chunk::<2>());
|
||||
///
|
||||
@ -550,9 +536,9 @@ pub const fn split_last_chunk_mut<const N: usize>(
|
||||
/// let w: &[i32] = &[];
|
||||
/// assert_eq!(Some(&[]), w.last_chunk::<0>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
|
||||
pub const fn last_chunk<const N: usize>(&self) -> Option<&[T; N]> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -574,8 +560,6 @@ pub const fn split_last_chunk_mut<const N: usize>(
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_first_last_chunk)]
|
||||
///
|
||||
/// let x = &mut [0, 1, 2];
|
||||
///
|
||||
/// if let Some(last) = x.last_chunk_mut::<2>() {
|
||||
@ -586,9 +570,9 @@ pub const fn split_last_chunk_mut<const N: usize>(
|
||||
///
|
||||
/// assert_eq!(None, x.last_chunk_mut::<4>());
|
||||
/// ```
|
||||
#[unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[rustc_const_unstable(feature = "slice_first_last_chunk", issue = "111774")]
|
||||
#[inline]
|
||||
#[stable(feature = "slice_first_last_chunk", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_unstable(feature = "const_slice_first_last_chunk", issue = "111774")]
|
||||
pub const fn last_chunk_mut<const N: usize>(&mut self) -> Option<&mut [T; N]> {
|
||||
if self.len() < N {
|
||||
None
|
||||
@ -1885,7 +1869,6 @@ pub fn group_by_mut<F>(&mut self, pred: F) -> GroupByMut<'_, T, F>
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_stable(feature = "const_slice_split_at_not_mut", since = "1.71.0")]
|
||||
#[rustc_allow_const_fn_unstable(slice_split_at_unchecked)]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
@ -1972,7 +1955,10 @@ pub const fn split_at_mut(&mut self, mid: usize) -> (&mut [T], &mut [T]) {
|
||||
/// }
|
||||
/// ```
|
||||
#[unstable(feature = "slice_split_at_unchecked", reason = "new API", issue = "76014")]
|
||||
#[rustc_const_unstable(feature = "slice_split_at_unchecked", issue = "76014")]
|
||||
#[rustc_const_stable(
|
||||
feature = "const_slice_split_at_unchecked",
|
||||
since = "CURRENT_RUSTC_VERSION"
|
||||
)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn split_at_unchecked(&self, mid: usize) -> (&[T], &[T]) {
|
||||
|
@ -46,7 +46,6 @@
|
||||
#![feature(pattern)]
|
||||
#![feature(sort_internals)]
|
||||
#![feature(slice_take)]
|
||||
#![feature(slice_first_last_chunk)]
|
||||
#![feature(slice_from_ptr_range)]
|
||||
#![feature(slice_split_once)]
|
||||
#![feature(split_as_slice)]
|
||||
|
Loading…
Reference in New Issue
Block a user