Open
Description
Feature gate: #![feature(maybe_uninit_write_slice)]
This is a tracking issue for MaybeUninit::copy_from_slice
and MaybeUninit::clone_from_slice
.
These methods are the equivalents of [T]::copy_from_slice
and [T]::clone_from_slice
for uninitialized slices.
Public API
impl<T> [MaybeUninit<T>] {
pub fn write_copy_of_slice(&mut self, src: &[T]) -> &mut [T]
where
T: Copy;
pub fn write_clone_of_slice(&mut self, src: &[T]) -> &mut [T]
where
T: Clone;
}
Steps / History
- Implementation: MaybeUninit::copy/clone_from_slice #79607
- Make slice methods inherent: Add inherent versions of MaybeUninit methods for slices #129259
- Stabilization PR
Unresolved Questions
- Should the name be changed back to
copy/clone_from_slice
?- Reasoning for the original name and Revamp unstable MaybeUninit APIs libs-team#122
- Changed to
copy_from_slice
andclone_from_slice
in Rename MaybeUninit::write_slice #116385 - Changed again to
write_copy_of_slice
andwrite_clone_of_slice
in Add inherent versions of MaybeUninit methods for slices #129259
- MaybeUninit::write_slice_cloned() makes it very easy to accidentally leak #80376