@@ -135,19 +135,12 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
135
135
Fold : FnMut ( Acc , Self :: Item ) -> Acc ,
136
136
{
137
137
let data = & mut self . data ;
138
- // FIXME: This uses try_fold(&mut iter) instead of fold(iter) because the latter
139
- // would go through the blanket `impl Iterator for &mut I` implementation
140
- // which lacks inline annotations on its methods and adding those would be a larger
141
- // perturbation than using try_fold here.
142
- // Whether it would be beneficial to add those annotations should be investigated separately.
143
- ( & mut self . alive )
144
- . try_fold :: < _ , _ , Result < _ , !> > ( init, |acc, idx| {
145
- // SAFETY: idx is obtained by folding over the `alive` range, which implies the
146
- // value is currently considered alive but as the range is being consumed each value
147
- // we read here will only be read once and then considered dead.
148
- Ok ( fold ( acc, unsafe { data. get_unchecked ( idx) . assume_init_read ( ) } ) )
149
- } )
150
- . unwrap ( )
138
+ self . alive . by_ref ( ) . fold ( init, |acc, idx| {
139
+ // SAFETY: idx is obtained by folding over the `alive` range, which implies the
140
+ // value is currently considered alive but as the range is being consumed each value
141
+ // we read here will only be read once and then considered dead.
142
+ fold ( acc, unsafe { data. get_unchecked ( idx) . assume_init_read ( ) } )
143
+ } )
151
144
}
152
145
153
146
fn count ( self ) -> usize {
0 commit comments