Skip to content

Tracking issue for missing Iterator::size_hint implementations #49205

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

Closed
24 of 62 tasks
Phlosioneer opened this issue Mar 20, 2018 · 2 comments
Closed
24 of 62 tasks

Tracking issue for missing Iterator::size_hint implementations #49205

Phlosioneer opened this issue Mar 20, 2018 · 2 comments
Labels
A-iterators Area: Iterators C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Phlosioneer
Copy link
Contributor

Phlosioneer commented Mar 20, 2018

size_hint() can sometimes allow for more efficient memory allocations, and other good performance things.

I intend to make a PR to implement the trivial / easy ones, at least. I've already made a PR for the first batch, #49201. The ones in that PR are omitted from this list.

This list will be updated as I sort through for false-positives.

Liballoc:

Libcore:

Libfmt_macros:

Libproc_macro:

  • TokenTreeIter Implementation is not trivial. It would be nice to do it eventually, though.

Librustc:

Librustdoc:

Libstd:

Libsyntax:

Cargo:
rust-lang/cargo#5211

I found them by running grep -r -n "impl.*\bIterator for \|fn size_hint" src > size_hint_todo.txt. Then, delete any pairs of an Iterator line followed by a size_hint line, and manually check the remaining Iterator lines for false positives.

It may be a good idea to make a lint for implementing size_hint. It would be opt-in, of course. It's really easy to forget, even if you're trying to optimize performance.

@pietroalbini pietroalbini added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC labels Mar 21, 2018
Phlosioneer added a commit to Phlosioneer/rust that referenced this issue Apr 1, 2018
Continues work on adding size_hint implementations for iterators:
issue rust-lang#49205
Phlosioneer added a commit to Phlosioneer/rust that referenced this issue Apr 1, 2018
Phlosioneer added a commit to Phlosioneer/rust that referenced this issue Apr 25, 2018
This continues work on issue rust-lang#49205.

This PR also implements ExactSizeIterator and FusedIterator where
they make sense.
@jonas-schievink jonas-schievink added the A-iterators Area: Iterators label Nov 26, 2019
@KodrAus KodrAus added the Libs-Tracked Libs issues that are tracked on the team's project board. label Jul 29, 2020
@KodrAus
Copy link
Contributor

KodrAus commented Aug 22, 2020

It looks like this one has been idle for a few years with PRs closed (mostly just from inactivity). In an effort to prune our open tracking issues to those with unstable features and those that are in progress I’ll go ahead and close this one, but if anybody from @rust-lang/libs thinks we should keep it open please feel free to re-open!

@KodrAus KodrAus closed this as completed Aug 22, 2020
@Phlosioneer
Copy link
Contributor Author

Phlosioneer commented Aug 22, 2020

I went through several of them. ToLowercase, ToUppercase, and CaseMappingIter are the only ones that are both trivial and possibly useful.

I don't have a local fork of rust setup anymore, but the code should be pretty simple. The PR that I opened #50208 was dropped because I wasn't interested in writing tests, and I wanted to add traits; but the code for those three size_hints alone should be fine. It's ~10 LoC plus tests.

Writing this comment for anyone in the future seeing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-iterators Area: Iterators C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC Libs-Tracked Libs issues that are tracked on the team's project board. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants