about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorBenoît du Garreau <bdgdlm@outlook.com>2021-05-11 13:00:34 +0200
committerBenoît du Garreau <bdgdlm@outlook.com>2021-05-11 13:00:34 +0200
commit9332ac3bfca0dad696127267ba8029677795b4ce (patch)
tree709b35bfbd13df1fae1ccddeb9d4a210c5a350dc /library/std/src
parentfe62c6e2958abfe54a9410a24a5750baf4c157e0 (diff)
downloadrust-9332ac3bfca0dad696127267ba8029677795b4ce.tar.gz
rust-9332ac3bfca0dad696127267ba8029677795b4ce.zip
Override `clone_from` for some types
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/io/cursor.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/library/std/src/io/cursor.rs b/library/std/src/io/cursor.rs
index 9021b470065..9527254c947 100644
--- a/library/std/src/io/cursor.rs
+++ b/library/std/src/io/cursor.rs
@@ -71,7 +71,7 @@ use core::convert::TryInto;
 /// }
 /// ```
 #[stable(feature = "rust1", since = "1.0.0")]
-#[derive(Clone, Debug, Default, Eq, PartialEq)]
+#[derive(Debug, Default, Eq, PartialEq)]
 pub struct Cursor<T> {
     inner: T,
     pos: u64,
@@ -206,6 +206,23 @@ impl<T> Cursor<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
+impl<T> Clone for Cursor<T>
+where
+    T: Clone,
+{
+    #[inline]
+    fn clone(&self) -> Self {
+        Cursor { inner: self.inner.clone(), pos: self.pos }
+    }
+
+    #[inline]
+    fn clone_from(&mut self, other: &Self) {
+        self.inner.clone_from(&other.inner);
+        self.pos = other.pos;
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<T> io::Seek for Cursor<T>
 where
     T: AsRef<[u8]>,