Skip to content

Commit 2276c5e

Browse files
committed
from review: add a comment why try_fold was chosen instead of fold
1 parent e015e9d commit 2276c5e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/array/iter.rs

+5
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ impl<T, const N: usize> Iterator for IntoIter<T, N> {
129129
Fold: FnMut(Acc, Self::Item) -> Acc,
130130
{
131131
let data = &mut self.data;
132+
// FIXME: This uses try_fold(&mut iter) instead of fold(iter) because the latter
133+
// would go through the blanket `impl Iterator for &mut I` implementation
134+
// which lacks inline annotations on its methods and adding those would be a larger
135+
// perturbation than using try_fold here.
136+
// Whether it would be beneficial to add those annotations should be investigated separately.
132137
(&mut self.alive)
133138
.try_fold::<_, _, Result<_, !>>(init, |acc, idx| {
134139
// SAFETY: idx is obtained by folding over the `alive` range, which implies the

0 commit comments

Comments
 (0)