about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/mem.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs
index a57d8355289..4cc0a5e49d9 100644
--- a/src/libcore/mem.rs
+++ b/src/libcore/mem.rs
@@ -821,6 +821,7 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
 /// ```
 #[stable(feature = "manually_drop", since = "1.20.0")]
 #[allow(unions_with_drop_fields)]
+#[derive(Copy)]
 pub union ManuallyDrop<T>{ value: T }
 
 impl<T> ManuallyDrop<T> {
@@ -899,6 +900,19 @@ impl<T: ::fmt::Debug> ::fmt::Debug for ManuallyDrop<T> {
     }
 }
 
+#[stable(feature = "manually_drop", since = "1.20.0")]
+impl<T: Clone> Clone for ManuallyDrop<T> {
+    fn clone(&self) -> Self {
+        use ::ops::Deref;
+        ManuallyDrop::new(self.deref().clone())
+    }
+
+    fn clone_from(&mut self, source: &Self) {
+        use ::ops::DerefMut;
+        self.deref_mut().clone_from(source);
+    }
+}
+
 /// Tells LLVM that this point in the code is not reachable, enabling further
 /// optimizations.
 ///