Make slice::as_flattened_mut unstably const

Tracking issue: https://github.com/rust-lang/rust/issues/95629

Unblocked by const_mut_refs being stabilized: https://github.com/rust-lang/rust/pull/129195
This commit is contained in:
DaniPopes 2024-12-30 18:16:28 +01:00
parent f95c996750
commit 26f523edfc
No known key found for this signature in database
GPG key ID: 0F09640DDB7AC692

View file

@ -4821,7 +4821,8 @@ 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")]
pub fn as_flattened_mut(&mut self) -> &mut [T] {
#[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")]
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")
} else {