Skip to content

Commit

Permalink
Rollup merge of rust-lang#134927 - DaniPopes:const-as_flattened_mut, …
Browse files Browse the repository at this point in the history
…r=scottmcm

Make slice::as_flattened_mut unstably const

Tracking issue: rust-lang#95629

Unblocked by const_mut_refs being stabilized: rust-lang#129195
  • Loading branch information
Zalathar authored Dec 31, 2024
2 parents a777f4a + 26f523e commit 1200d3d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1200d3d

Please sign in to comment.