about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorFrank Steffahn <frank.steffahn@stu.uni-kiel.de>2021-05-30 01:03:34 +0200
committerFrank Steffahn <frank.steffahn@stu.uni-kiel.de>2021-05-30 01:03:34 +0200
commitb4dcdb4b473304b1c52b1ba79bc174d208107cdc (patch)
tree3c82ac9ff0bd961515588d76010dafb5fc005497 /library/alloc
parent7d364ad7c48820dafdc6319bc4de0d2185087a14 (diff)
downloadrust-b4dcdb4b473304b1c52b1ba79bc174d208107cdc.tar.gz
rust-b4dcdb4b473304b1c52b1ba79bc174d208107cdc.zip
Improve Debug impls for LinkedList reference iterators to show items
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/collections/linked_list.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs
index fac9a548415..1a58ad51f78 100644
--- a/library/alloc/src/collections/linked_list.rs
+++ b/library/alloc/src/collections/linked_list.rs
@@ -64,7 +64,15 @@ pub struct Iter<'a, T: 'a> {
 #[stable(feature = "collection_debug", since = "1.17.0")]
 impl<T: fmt::Debug> fmt::Debug for Iter<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_tuple("Iter").field(&self.len).finish()
+        f.debug_tuple("Iter")
+            .field(&*mem::ManuallyDrop::new(LinkedList {
+                head: self.head,
+                tail: self.tail,
+                len: self.len,
+                marker: PhantomData,
+            }))
+            .field(&self.len)
+            .finish()
     }
 }
 
@@ -91,7 +99,15 @@ pub struct IterMut<'a, T: 'a> {
 #[stable(feature = "collection_debug", since = "1.17.0")]
 impl<T: fmt::Debug> fmt::Debug for IterMut<'_, T> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        f.debug_tuple("IterMut").field(&self.len).finish()
+        f.debug_tuple("IterMut")
+            .field(&*mem::ManuallyDrop::new(LinkedList {
+                head: self.head,
+                tail: self.tail,
+                len: self.len,
+                marker: PhantomData,
+            }))
+            .field(&self.len)
+            .finish()
     }
 }