@@ -924,7 +924,7 @@ const fn try_from_fn_erased<R: [const] Try<Output: [const] Destruct>>(
924924/// All write accesses to this structure are unsafe and must maintain a correct
925925/// count of `initialized` elements.
926926///
927- /// To minimize indirection fields are still pub but callers should at least use
927+ /// To minimize indirection, fields are still pub but callers should at least use
928928/// `push_unchecked` to signal that something unsafe is going on.
929929 struct Guard <' a, T > {
930930 /// The array to be initialized.
@@ -943,7 +943,7 @@ impl<T> Guard<'_, T> {
943943 #[ rustc_const_unstable ( feature = "array_try_from_fn" , issue = "89379" ) ]
944944 pub( crate ) const unsafe fn push_unchecked ( & mut self , item : T ) {
945945 // SAFETY: If `initialized` was correct before and the caller does not
946- // invoke this method more than N times then writes will be in-bounds
946+ // invoke this method more than N times, then writes will be in-bounds
947947 // and slots will not be initialized more than once.
948948 unsafe {
949949 self . array_mut. get_unchecked_mut( self . initialized) . write( item) ;
@@ -972,7 +972,7 @@ impl<T: [const] Destruct> const Drop for Guard<'_, T> {
972972 /// `next` at most `N ` times, the iterator can still be used afterwards to
973973/// retrieve the remaining items.
974974 ///
975- /// If `iter.next()` panicks , all items already yielded by the iterator are
975+ /// If `iter.next()` panics , all items already yielded by the iterator are
976976 /// dropped.
977977///
978978 /// Used for [ `Iterator :: next_chunk`] .
@@ -1004,6 +1004,7 @@ fn iter_next_chunk_erased<T>(
10041004 buffer : & mut [ MaybeUninit < T > ] ,
10051005 iter : & mut impl Iterator < Item = T > ,
10061006) -> Result < ( ) , usize > {
1007+ // if `Iterator::next` panics, this guard will drop already initialized items
10071008 let mut guard = Guard { array_mut : buffer, initialized : 0 } ;
10081009 while guard. initialized < guard. array_mut . len ( ) {
10091010 let Some ( item) = iter. next ( ) else {
0 commit comments