Skip to content

Commit

Permalink
Stabilize const_slice_flatten
Browse files Browse the repository at this point in the history
Const-stabilizes `slice::as_flattened{,_mut}`:
```rust
// core::slice
impl<T, const N: usize> [[T; N]] {
    pub const fn as_flattened(&self) -> &[T];
    pub const fn as_flattened_mut(&mut self) -> &mut [T];
}
```

Tracking issue: #95629

Requires separate libs-api FCP, as per #95629 (comment).

Closes #95629.
  • Loading branch information
DaniPopes committed Jan 1, 2025
1 parent eeeff9a commit 7de250f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4784,7 +4784,7 @@ impl<T, const N: usize> [[T; N]] {
/// assert!(empty_slice_of_arrays.as_flattened().is_empty());
/// ```
#[stable(feature = "slice_flatten", since = "1.80.0")]
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_flattened(&self) -> &[T] {
let len = if T::IS_ZST {
self.len().checked_mul(N).expect("slice len overflow")
Expand Down Expand Up @@ -4821,7 +4821,7 @@ impl<T, const N: usize> [[T; N]] {
/// assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]);
/// ```
#[stable(feature = "slice_flatten", since = "1.80.0")]
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
#[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_flattened_mut(&mut self) -> &mut [T] {
let len = if T::IS_ZST {
self.len().checked_mul(N).expect("slice len overflow")
Expand Down

0 comments on commit 7de250f

Please sign in to comment.