Skip to content

QueryIter implements ExactSizeIterator, but doesnt provide an exact size_hint #1686

@MinerSebas

Description

@MinerSebas

Bevy version

cd4c684

What you did

I read the documentation of ExactSizeIterator, and notice that this requirement isn't true:

When implementing an ExactSizeIterator, you must also implement Iterator.
When doing so, the implementation of Iterator::size_hint must return the exact size of the iterator.

In the standard implementation this is checked with an assertion.

Instead of providing an exact size_hint, Bevy overrides that function, which removes the need for that invariant to be true.

While it isn't a problem here, it would still be nice if QueryIter would provide an exact size_hint if it can.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-Code-QualityA section of code that is hard to understand or changeC-PerformanceA change motivated by improving speed, memory usage or compile times

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions