@@ -907,7 +907,7 @@ where
907907/// All write accesses to this structure are unsafe and must maintain a correct
908908/// count of `initialized` elements.
909909///
910- /// To minimize indirection fields are still pub but callers should at least use
910+ /// To minimize indirection, fields are still pub but callers should at least use
911911/// `push_unchecked` to signal that something unsafe is going on.
912912struct Guard < ' a , T > {
913913 /// The array to be initialized.
@@ -925,7 +925,7 @@ impl<T> Guard<'_, T> {
925925 #[ inline]
926926 pub ( crate ) unsafe fn push_unchecked ( & mut self , item : T ) {
927927 // SAFETY: If `initialized` was correct before and the caller does not
928- // invoke this method more than N times then writes will be in-bounds
928+ // invoke this method more than N times, then writes will be in-bounds
929929 // and slots will not be initialized more than once.
930930 unsafe {
931931 self . array_mut . get_unchecked_mut ( self . initialized ) . write ( item) ;
@@ -954,7 +954,7 @@ impl<T> Drop for Guard<'_, T> {
954954/// `next` at most `N` times, the iterator can still be used afterwards to
955955/// retrieve the remaining items.
956956///
957- /// If `iter.next()` panicks , all items already yielded by the iterator are
957+ /// If `iter.next()` panics , all items already yielded by the iterator are
958958/// dropped.
959959///
960960/// Used for [`Iterator::next_chunk`].
@@ -986,6 +986,7 @@ fn iter_next_chunk_erased<T>(
986986 buffer : & mut [ MaybeUninit < T > ] ,
987987 iter : & mut impl Iterator < Item = T > ,
988988) -> Result < ( ) , usize > {
989+ // if `Iterator::next` panics, this guard will drop already initialized items
989990 let mut guard = Guard { array_mut : buffer, initialized : 0 } ;
990991 while guard. initialized < guard. array_mut . len ( ) {
991992 let Some ( item) = iter. next ( ) else {
0 commit comments