File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -533,11 +533,14 @@ unsafe fn collect_into_array_unchecked<I, const N: usize>(iter: &mut I) -> [I::I
533533where
534534 I : Iterator + TrustedLen ,
535535{
536- let mut map = iter. map ( |el| Ok :: < _ , Infallible > ( el ) ) ;
536+ let mut map = iter. map ( Ok :: < _ , Infallible > ) ;
537537
538- // SAFETY: Valid array elements are covered by the fact that all passed values
539- // to `collect_into_array` are `Ok`.
540- unsafe { collect_into_array_rslt_unchecked ( & mut map) . unwrap_unchecked ( ) }
538+ // SAFETY: The same safety considerations w.r.t. the iterator length
539+ // apply for `collect_into_array_rslt_unchecked` as for
540+ // `collect_into_array_unchecked`
541+ match unsafe { collect_into_array_rslt_unchecked ( & mut map) } {
542+ Ok ( array) => array,
543+ }
541544}
542545
543546/// Pulls `N` items from `iter` and returns them as an array. If the iterator
You can’t perform that action at this time.
0 commit comments