Skip to content

Commit 1a1ebb0

Browse files
committed
Make transpose const and inline
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
1 parent 8be3ce9 commit 1a1ebb0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@
217217
#![feature(unboxed_closures)]
218218
#![feature(unsized_fn_params)]
219219
#![feature(asm_const)]
220+
#![feature(const_transmute_copy)]
220221
//
221222
// Target features:
222223
#![feature(arm_target_feature)]

Diff for: library/core/src/mem/maybe_uninit.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,8 @@ impl<T, const N: usize> MaybeUninit<[T; N]> {
12971297
/// let data: [MaybeUninit<u8>; 1000] = MaybeUninit::uninit().transpose();
12981298
/// ```
12991299
#[unstable(feature = "maybe_uninit_uninit_array_transpose", issue = "96097")]
1300-
pub fn transpose(self) -> [MaybeUninit<T>; N] {
1300+
#[inline]
1301+
pub const fn transpose(self) -> [MaybeUninit<T>; N] {
13011302
// SAFETY: T and MaybeUninit<T> have the same layout
13021303
unsafe { super::transmute_copy(&ManuallyDrop::new(self)) }
13031304
}
@@ -1316,7 +1317,8 @@ impl<T, const N: usize> [MaybeUninit<T>; N] {
13161317
/// let data: MaybeUninit<[u8; 1000]> = data.transpose();
13171318
/// ```
13181319
#[unstable(feature = "maybe_uninit_uninit_array_transpose", issue = "96097")]
1319-
pub fn transpose(self) -> MaybeUninit<[T; N]> {
1320+
#[inline]
1321+
pub const fn transpose(self) -> MaybeUninit<[T; N]> {
13201322
// SAFETY: T and MaybeUninit<T> have the same layout
13211323
unsafe { super::transmute_copy(&ManuallyDrop::new(self)) }
13221324
}

0 commit comments

Comments
 (0)