about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-17 20:35:22 +0200
committerGitHub <noreply@github.com>2020-04-17 20:35:22 +0200
commit07cb4f44e4b159a6be3e837be5b9c134f51f2485 (patch)
treeb8ce97b18c1d066debab832a111c23ce160af792 /src/liballoc
parentd30292caa73db141e9a69a5ad7f7557a8752615d (diff)
parent22e51cd78a81b5dc9be915f975c6c05721fe5797 (diff)
downloadrust-07cb4f44e4b159a6be3e837be5b9c134f51f2485.tar.gz
rust-07cb4f44e4b159a6be3e837be5b9c134f51f2485.zip
Rollup merge of #71246 - crlf0710:linked_list_cursor, r=Amanieu
Implement `Clone` for `liballoc::collections::linked_list::Cursor`.

This implements `Clone` for linked list `Cursor`. Implementing `Copy` is also possible here, but i'm not sure whether i should also do it.

r? @Amanieu
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/collections/linked_list.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs
index 53d4f7239b7..243ebb453d3 100644
--- a/src/liballoc/collections/linked_list.rs
+++ b/src/liballoc/collections/linked_list.rs
@@ -1198,6 +1198,14 @@ pub struct Cursor<'a, T: 'a> {
 }
 
 #[unstable(feature = "linked_list_cursors", issue = "58533")]
+impl<T> Clone for Cursor<'_, T> {
+    fn clone(&self) -> Self {
+        let Cursor { index, current, list } = *self;
+        Cursor { index, current, list }
+    }
+}
+
+#[unstable(feature = "linked_list_cursors", issue = "58533")]
 impl<T: fmt::Debug> fmt::Debug for Cursor<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_tuple("Cursor").field(&self.list).field(&self.index()).finish()