Skip to content

Commit

Permalink
Make slice::as_flattened_mut unstably const
Browse files Browse the repository at this point in the history
Tracking issue: #95629

Unblocked by const_mut_refs being stabilized: #129195
  • Loading branch information
DaniPopes committed Dec 30, 2024
1 parent f95c996 commit 26f523e
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 26f523e

Please sign in to comment.