Skip to content
Permalink
Browse files

make MaybeUninit Copy

  • Loading branch information...
RalfJung committed Feb 22, 2019
1 parent d10366f commit aa4a9b0827f09efa8a06d99df6cae07b21e6729c
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/libcore/mem.rs
@@ -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.
///

0 comments on commit aa4a9b0

Please sign in to comment.
You can’t perform that action at this time.