mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Stabilize slice_as_chunks
library feature
This commit is contained in:
parent
56c08d9b32
commit
6cfdd53da1
@ -31,7 +31,6 @@
|
||||
#![feature(round_char_boundary)]
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(rustdoc_internals)]
|
||||
#![feature(slice_as_chunks)]
|
||||
// tidy-alphabetical-end
|
||||
|
||||
// The code produced by the `Encodable`/`Decodable` derive macros refer to
|
||||
|
@ -119,7 +119,6 @@
|
||||
#![feature(ptr_metadata)]
|
||||
#![feature(set_ptr_value)]
|
||||
#![feature(slice_as_array)]
|
||||
#![feature(slice_as_chunks)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![feature(str_internals)]
|
||||
#![feature(str_split_inclusive_remainder)]
|
||||
|
@ -2335,7 +2335,6 @@ pub struct ArrayChunks<'a, T: 'a, const N: usize> {
|
||||
|
||||
impl<'a, T, const N: usize> ArrayChunks<'a, T, N> {
|
||||
#[rustc_const_unstable(feature = "const_slice_make_iter", issue = "137737")]
|
||||
// #[rustc_const_unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[inline]
|
||||
pub(super) const fn new(slice: &'a [T]) -> Self {
|
||||
let (array_slice, rem) = slice.as_chunks();
|
||||
|
@ -1271,7 +1271,6 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let slice: &[char] = &['l', 'o', 'r', 'e', 'm', '!'];
|
||||
/// let chunks: &[[char; 1]] =
|
||||
/// // SAFETY: 1-element chunks never have remainder
|
||||
@ -1286,7 +1285,8 @@ impl<T> [T] {
|
||||
/// // let chunks: &[[_; 5]] = slice.as_chunks_unchecked() // The slice length is not a multiple of 5
|
||||
/// // let chunks: &[[_; 0]] = slice.as_chunks_unchecked() // Zero-length chunks are never allowed
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn as_chunks_unchecked<const N: usize>(&self) -> &[[T; N]] {
|
||||
@ -1314,7 +1314,6 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let slice = ['l', 'o', 'r', 'e', 'm'];
|
||||
/// let (chunks, remainder) = slice.as_chunks();
|
||||
/// assert_eq!(chunks, &[['l', 'o'], ['r', 'e']]);
|
||||
@ -1324,14 +1323,14 @@ impl<T> [T] {
|
||||
/// If you expect the slice to be an exact multiple, you can combine
|
||||
/// `let`-`else` with an empty slice pattern:
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let slice = ['R', 'u', 's', 't'];
|
||||
/// let (chunks, []) = slice.as_chunks::<2>() else {
|
||||
/// panic!("slice didn't have even length")
|
||||
/// };
|
||||
/// assert_eq!(chunks, &[['R', 'u'], ['s', 't']]);
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
@ -1359,13 +1358,13 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let slice = ['l', 'o', 'r', 'e', 'm'];
|
||||
/// let (remainder, chunks) = slice.as_rchunks();
|
||||
/// assert_eq!(remainder, &['l']);
|
||||
/// assert_eq!(chunks, &[['o', 'r'], ['e', 'm']]);
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
@ -1427,7 +1426,6 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let slice: &mut [char] = &mut ['l', 'o', 'r', 'e', 'm', '!'];
|
||||
/// let chunks: &mut [[char; 1]] =
|
||||
/// // SAFETY: 1-element chunks never have remainder
|
||||
@ -1444,7 +1442,8 @@ impl<T> [T] {
|
||||
/// // let chunks: &[[_; 5]] = slice.as_chunks_unchecked_mut() // The slice length is not a multiple of 5
|
||||
/// // let chunks: &[[_; 0]] = slice.as_chunks_unchecked_mut() // Zero-length chunks are never allowed
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const unsafe fn as_chunks_unchecked_mut<const N: usize>(&mut self) -> &mut [[T; N]] {
|
||||
@ -1472,7 +1471,6 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let v = &mut [0, 0, 0, 0, 0];
|
||||
/// let mut count = 1;
|
||||
///
|
||||
@ -1484,7 +1482,8 @@ impl<T> [T] {
|
||||
/// }
|
||||
/// assert_eq!(v, &[1, 1, 2, 2, 9]);
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
@ -1512,7 +1511,6 @@ impl<T> [T] {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(slice_as_chunks)]
|
||||
/// let v = &mut [0, 0, 0, 0, 0];
|
||||
/// let mut count = 1;
|
||||
///
|
||||
@ -1524,7 +1522,8 @@ impl<T> [T] {
|
||||
/// }
|
||||
/// assert_eq!(v, &[9, 1, 1, 2, 2]);
|
||||
/// ```
|
||||
#[unstable(feature = "slice_as_chunks", issue = "74985")]
|
||||
#[stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[rustc_const_stable(feature = "slice_as_chunks", since = "CURRENT_RUSTC_VERSION")]
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[must_use]
|
||||
|
@ -1,7 +1,6 @@
|
||||
//@revisions: stack tree
|
||||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
//@compile-flags: -Zmiri-strict-provenance
|
||||
#![feature(slice_as_chunks)]
|
||||
#![feature(slice_partition_dedup)]
|
||||
#![feature(layout_for_ptr)]
|
||||
|
||||
@ -227,7 +226,7 @@ fn test_for_invalidated_pointers() {
|
||||
|
||||
buffer.reverse();
|
||||
|
||||
// Calls `fn as_chunks_unchecked_mut` internally (requires unstable `#![feature(slice_as_chunks)]`):
|
||||
// Calls `fn as_chunks_unchecked_mut` internally:
|
||||
assert_eq!(2, buffer.as_chunks_mut::<32>().0.len());
|
||||
for chunk in buffer.as_chunks_mut::<32>().0 {
|
||||
for elem in chunk {
|
||||
|
@ -2,7 +2,6 @@
|
||||
//@ only-64bit (because the LLVM type of i64 for usize shows up)
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(slice_as_chunks)]
|
||||
|
||||
// CHECK-LABEL: @chunks4
|
||||
#[no_mangle]
|
||||
|
Loading…
Reference in New Issue
Block a user