Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .size_hint() implementation for ArchiveSymbolIterator #759

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MEhrn00
Copy link

@MEhrn00 MEhrn00 commented Mar 2, 2025

This PR adds a .size_hint() implementation to the ArchiveSymbolIterator.

The value returned for this is the size hint value of the underlying slice::Iter. This provides the most accurate size hint without needing to add additional fields for keeping track of the iterator's state.

I have been working on a project where it would be nice to pre-allocate collections based on the number of symbols inside an archive's symbol map. The default .size_hint() implementation returns 0 and there is no API in this library that will get this value.

This uses the size hint value from the underlying `slice::Iter`. The
iterator itself does not track the symbol count so this slice iter
provides the most accurate value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant