Stabilize const_slice_flatten
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: https://github.com/rust-lang/rust/issues/95629
Requires separate libs-api FCP, as per https://github.com/rust-lang/rust/issues/95629#issuecomment-2566546257.
Closes https://github.com/rust-lang/rust/issues/95629.
This commit is contained in:
parent
eeeff9a66c
commit
7de250f1e3
1 changed files with 2 additions and 2 deletions
|
|
@ -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")
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue