Closed
Description
Bevy version
Problem
The [ExactSizeIterator
] docs imply that the value returned by len()
should change as the iterator is partially consumed.
Our implementations do not do this.
We should carefully check to ensure that our size_hint
methods are correct too.
Possible solutions
Solution 1: track directly
This solution solves the problem at hand, but creates unavoidable overhead in cases where we don't care.
Solution 2: create a ExactSizeQueryIter
type
Only implement the ExactSizeIterator
trait for this type.
Avoids overhead, gains the correct behavior, but ergonomics are a bit meh.
If we do this, this must be documented carefully.
Solution 3: scrap the ExactSizeIterator trait, and implement len()
directly
This is a bit sad, because it reduces compatibility with other ecosystem crates that care about this trait.
Solution 4: YOLO
Keep the current behavior that does not comply with the spec. The docs do say you can't rely on this for soundness...