Skip to content

Commit

Permalink
make MaybeUninit Copy
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 22, 2019
1 parent d10366f commit aa4a9b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libcore/mem.rs
Expand Up @@ -1106,12 +1106,22 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
// FIXME before stabilizing, explain how to initialize a struct field-by-field.
#[allow(missing_debug_implementations)]
#[unstable(feature = "maybe_uninit", issue = "53491")]
#[derive(Copy)]
// NOTE after stabilizing `MaybeUninit` proceed to deprecate `mem::uninitialized`
pub union MaybeUninit<T> {
uninit: (),
value: ManuallyDrop<T>,
}

#[unstable(feature = "maybe_uninit", issue = "53491")]
impl<T: Copy> Clone for MaybeUninit<T> {
#[inline(always)]
fn clone(&self) -> Self {
// Not calling T::clone(), we cannot know if we are initialized enough for that.
*self
}
}

impl<T> MaybeUninit<T> {
/// Create a new `MaybeUninit` initialized with the given value.
///
Expand Down

0 comments on commit aa4a9b0

Please sign in to comment.