@@ -60,10 +60,17 @@ impl<'a, T> IntoIterator for &'a mut [T] {
60
60
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
61
61
#[ must_use = "iterators are lazy and do nothing unless consumed" ]
62
62
pub struct Iter < ' a , T : ' a > {
63
+ /// The pointer to the next element to return, or the past-the-end location
64
+ /// if the iterator is empty.
65
+ ///
66
+ /// This address will be used for all ZST elements, never changed.
63
67
ptr : NonNull < T > ,
64
- end : * const T , // If T is a ZST, this is actually ptr+len. This encoding is picked so that
65
- // ptr == end is a quick test for the Iterator being empty, that works
66
- // for both ZST and non-ZST.
68
+ /// For non-ZSTs, the non-null pointer to the past-the-end element.
69
+ ///
70
+ /// For ZSTs, this is `ptr.wrapping_byte_add(len)`.
71
+ ///
72
+ /// For all types, `ptr == end` tests whether the iterator is empty.
73
+ end : * const T ,
67
74
_marker : PhantomData < & ' a T > ,
68
75
}
69
76
@@ -179,10 +186,17 @@ impl<T> AsRef<[T]> for Iter<'_, T> {
179
186
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
180
187
#[ must_use = "iterators are lazy and do nothing unless consumed" ]
181
188
pub struct IterMut < ' a , T : ' a > {
189
+ /// The pointer to the next element to return, or the past-the-end location
190
+ /// if the iterator is empty.
191
+ ///
192
+ /// This address will be used for all ZST elements, never changed.
182
193
ptr : NonNull < T > ,
183
- end : * mut T , // If T is a ZST, this is actually ptr+len. This encoding is picked so that
184
- // ptr == end is a quick test for the Iterator being empty, that works
185
- // for both ZST and non-ZST.
194
+ /// For non-ZSTs, the non-null pointer to the past-the-end element.
195
+ ///
196
+ /// For ZSTs, this is `ptr.wrapping_byte_add(len)`.
197
+ ///
198
+ /// For all types, `ptr == end` tests whether the iterator is empty.
199
+ end : * mut T ,
186
200
_marker : PhantomData < & ' a mut T > ,
187
201
}
188
202
0 commit comments