Add MaybeUninit array transpose impls by SUPERCILEX · Pull Request #102023 · rust-lang/rust (original) (raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: while this works fine, since none of it can panic, we try in the docs to follow the "pre-pit your peaches" order of things, rather than "forget it afterwards", and consider forget soft-deprecated.

So please update this to something like

pub fn transpose(self) -> [MaybeUninit<T>; N] {
    // SAFETY: T, ManuallyDrop<T>, and MaybeUninit<T> have the same layout
    unsafe { super::transmute_copy(&ManuallyDrop::new(self)) }
}

(And ditto for the one below)