@@ -64,7 +64,15 @@ pub struct Iter<'a, T: 'a> {
64
64
#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
65
65
impl < T : fmt:: Debug > fmt:: Debug for Iter < ' _ , T > {
66
66
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
67
- f. debug_tuple ( "Iter" ) . field ( & self . len ) . finish ( )
67
+ f. debug_tuple ( "Iter" )
68
+ . field ( & * mem:: ManuallyDrop :: new ( LinkedList {
69
+ head : self . head ,
70
+ tail : self . tail ,
71
+ len : self . len ,
72
+ marker : PhantomData ,
73
+ } ) )
74
+ . field ( & self . len )
75
+ . finish ( )
68
76
}
69
77
}
70
78
@@ -82,19 +90,24 @@ impl<T> Clone for Iter<'_, T> {
82
90
/// documentation for more.
83
91
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
84
92
pub struct IterMut < ' a , T : ' a > {
85
- // We do *not* exclusively own the entire list here, references to node's `element`
86
- // have been handed out by the iterator! So be careful when using this; the methods
87
- // called must be aware that there can be aliasing pointers to `element`.
88
- list : & ' a mut LinkedList < T > ,
89
93
head : Option < NonNull < Node < T > > > ,
90
94
tail : Option < NonNull < Node < T > > > ,
91
95
len : usize ,
96
+ marker : PhantomData < & ' a mut Node < T > > ,
92
97
}
93
98
94
99
#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
95
100
impl < T : fmt:: Debug > fmt:: Debug for IterMut < ' _ , T > {
96
101
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
97
- f. debug_tuple ( "IterMut" ) . field ( & self . list ) . field ( & self . len ) . finish ( )
102
+ f. debug_tuple ( "IterMut" )
103
+ . field ( & * mem:: ManuallyDrop :: new ( LinkedList {
104
+ head : self . head ,
105
+ tail : self . tail ,
106
+ len : self . len ,
107
+ marker : PhantomData ,
108
+ } ) )
109
+ . field ( & self . len )
110
+ . finish ( )
98
111
}
99
112
}
100
113
@@ -493,7 +506,7 @@ impl<T> LinkedList<T> {
493
506
#[ inline]
494
507
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
495
508
pub fn iter_mut ( & mut self ) -> IterMut < ' _ , T > {
496
- IterMut { head : self . head , tail : self . tail , len : self . len , list : self }
509
+ IterMut { head : self . head , tail : self . tail , len : self . len , marker : PhantomData }
497
510
}
498
511
499
512
/// Provides a cursor at the front element.
0 commit comments