@@ -60,10 +60,17 @@ impl<'a, T> IntoIterator for &'a mut [T] {
6060#[ stable( feature = "rust1" , since = "1.0.0" ) ]
6161#[ must_use = "iterators are lazy and do nothing unless consumed" ]
6262pub 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.
6367 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 ,
6774 _marker : PhantomData < & ' a T > ,
6875}
6976
@@ -179,10 +186,17 @@ impl<T> AsRef<[T]> for Iter<'_, T> {
179186#[ stable( feature = "rust1" , since = "1.0.0" ) ]
180187#[ must_use = "iterators are lazy and do nothing unless consumed" ]
181188pub 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.
182193 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 ,
186200 _marker : PhantomData < & ' a mut T > ,
187201}
188202
0 commit comments