Skip to content

Add is_empty function to ExactSizeIteratorΒ #35428

Open

Description

@frewsxcv

View all comments

Tracking issue for functionality introduced in #34357

Activity

  1. frewsxcv commented on Aug 6, 2016

    @frewsxcv
    ContributorAuthor

    Added reference to this issue in #35429

  2. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    on Aug 6, 2016
  3. added a commit that references this issue on Aug 7, 2016
  4. added 2 commits that reference this issue on Aug 7, 2016
  5. SimonSapin commented on Oct 17, 2016

    @SimonSapin
    Contributor

    I wanted to use this today until I realized that it’s unstable. (I could use .len() == 0 in the mean time.) Seems straightforward enough. FCP to stabilize?

  6. alexcrichton commented on Nov 1, 2016

    @alexcrichton
    Member

    @rfcbot fcp merge

    Seems good to have consistency!

  7. rfcbot commented on Nov 1, 2016

    @rfcbot

    Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams:

    No concerns currently listed.

    Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

    See this document for info about what commands tagged team members can give me.

  8. bluss commented on Nov 4, 2016

    @bluss
    Contributor

    @SimonSapin I'm curious, when do you use ExactSizeIterator and have the opportunity to use this?

  9. SimonSapin commented on Nov 5, 2016

    @SimonSapin
    Contributor

    When using a slice or vec iterator as input for a parser, .is_empty() is a way to tell "have I reach the end of the input yet?" https://github.com/servo/html5ever/blob/b5c4552fab/macros/match_token.rs#L175

  10. bluss commented on Nov 5, 2016

    @bluss
    Contributor

    Aha, that explains it for me: using a specific iterator type, not using ESI generically. This method is good, reinforces existing conventions.

  11. rfcbot commented on Nov 12, 2016

    @rfcbot

    πŸ”” This is now entering its final comment period, as per the review above. πŸ””

    psst @alexcrichton, I wasn't able to add the final-comment-period label, please do so.

  12. added
    final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
    on Nov 12, 2016
  13. rfcbot commented on Nov 22, 2016

    @rfcbot

    The final comment period is now complete.

  14. 72 remaining items

  15. added a commit that references this issue on Nov 29, 2021
  16. Walther commented on Mar 21, 2022

    @Walther
    Contributor

    Hello hi πŸ‘‹ Kindest little boop & status check - what is the status of this? The docs seem to still say this is nightly-only, experimental https://doc.rust-lang.org/std/iter/trait.ExactSizeIterator.html#method.is_empty

  17. scottmcm commented on Mar 21, 2022

    @scottmcm
    Member

    @Walther I think the same "people want this on non-ExactSizedIterators" contention still applies, and thus I expect it to stay unstable until someone has a solution for that.

    For now, .len() == 0 is often just as fast, so may suffice.

  18. clarfonthey commented on Mar 21, 2022

    @clarfonthey
    Contributor

    An alternative for the not fast case would be to just use peekable, but that does use up space and most people would prefer it to be usable without taking up extra space.

    Maybe a version like FusedIterator that makes Peekable fast might help?

    EDIT: I actually really like this and might offer up a PR.

  19. clarfonthey commented on Mar 22, 2022

    @clarfonthey
    Contributor

    So, I did the thing and offered up a PeekableIterator trait in #95195 as a potential path to an alternative. Feel free to put your thoughts there and whether you think this is a reasonable alternative or not.

  20. added a commit that references this issue on May 19, 2023
  21. Rua commented on Jul 11, 2025

    @Rua
    Contributor

    What is currently still needed to get this stabilised?

  22. clarfonthey commented on Jul 12, 2025

    @clarfonthey
    Contributor

    It's highly unlikely this will be stabilised considering how is_empty is a very reasonable operation on iterators that don't implement ExactSizeIterator.

    If you even checked the previous comment, mine, I mention PeekableIterator as a potential place to put it. While that PR was closed, peekable iterators have since had a proper ACP and can be tracked in #132973.

    There's a lot of baggage associated with this method, which is why it's not stabilised. It's not simply due to it being technically infeasible.

  23. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
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: IteratorsB-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCI-libs-radarLibs issues that are tracked on the team's radar.T-libsRelevant to the library 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

      Issue actions