Skip to content

Tracking issue for missing Iterator::size_hint implementations #49205

Closed
@Phlosioneer

Description

@Phlosioneer
Contributor

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:

  • Pattern: $forward_iterator<'a, P> Impossible to provide upper or lower bounds.
    Pattern: $reverse_iterator<'a, P> Impossible to provide upper or lower bounds.

Libfmt_macros:

  • Parser<'a> Both impossible and irrelevant.

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.

Activity

added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
on Mar 21, 2018
added a commit that references this issue on Apr 1, 2018
added
Libs-TrackedLibs issues that are tracked on the team's project board.
on Jul 29, 2020
KodrAus

KodrAus commented on Aug 22, 2020

@KodrAus
Contributor

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!

2 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-iteratorsArea: IteratorsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCLibs-TrackedLibs issues that are tracked on the team's project board.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jonas-schievink@pietroalbini@Phlosioneer@KodrAus

        Issue actions

          Tracking issue for missing Iterator::size_hint implementations · Issue #49205 · rust-lang/rust