You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add is_empty function to ExactSizeIteratorΒ #35428
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?
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.
@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.
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.
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.
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.
Activity
frewsxcv commentedon Aug 6, 2016
Added reference to this issue in #35429
Rollup merge of rust-lang#35429 - frewsxcv:tracking-is-empty, r=apaseβ¦
Rollup merge of rust-lang#35429 - frewsxcv:tracking-is-empty, r=apaseβ¦
Rollup merge of rust-lang#35429 - frewsxcv:tracking-is-empty, r=apaseβ¦
SimonSapin commentedon Oct 17, 2016
I wanted to use this today until I realized that itβs unstable. (I could use
.len() == 0in the mean time.) Seems straightforward enough. FCP to stabilize?alexcrichton commentedon Nov 1, 2016
@rfcbot fcp merge
Seems good to have consistency!
rfcbot commentedon Nov 1, 2016
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.
bluss commentedon Nov 4, 2016
@SimonSapin I'm curious, when do you use ExactSizeIterator and have the opportunity to use this?
SimonSapin commentedon Nov 5, 2016
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#L175bluss commentedon Nov 5, 2016
Aha, that explains it for me: using a specific iterator type, not using ESI generically. This method is good, reinforces existing conventions.
rfcbot commentedon Nov 12, 2016
π This is now entering its final comment period, as per the review above. π
psst @alexcrichton, I wasn't able to add the
final-comment-periodlabel, please do so.rfcbot commentedon Nov 22, 2016
The final comment period is now complete.
72 remaining items
feat: impl Iterator for errors
feat: impl Iterator for errors
feat: impl Iterator for errors
feat: impl Iterator for errors
feat: impl Iterator for errors
feat: impl Iterator for errors (#120)
Walther commentedon Mar 21, 2022
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
scottmcm commentedon Mar 21, 2022
@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() == 0is often just as fast, so may suffice.clarfonthey commentedon Mar 21, 2022
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
FusedIteratorthat makesPeekablefast might help?EDIT: I actually really like this and might offer up a PR.
clarfonthey commentedon Mar 22, 2022
So, I did the thing and offered up a
PeekableIteratortrait 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.iterator updates for immutable list
Rua commentedon Jul 11, 2025
What is currently still needed to get this stabilised?
clarfonthey commentedon Jul 12, 2025
It's highly unlikely this will be stabilised considering how
is_emptyis a very reasonable operation on iterators that don't implementExactSizeIterator.If you even checked the previous comment, mine, I mention
PeekableIteratoras 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.