Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd `is_empty` function to `ExactSizeIterator` #35428
Comments
This comment has been minimized.
This comment has been minimized.
|
Added reference to this issue in #35429 |
frewsxcv
referenced this issue
Aug 6, 2016
Merged
Indicate tracking issue for `exact_size_is_empty` unstability. #35429
apasel422
added
the
B-unstable
label
Aug 6, 2016
jonathandturner
added a commit
to jonathandturner/rust
that referenced
this issue
Aug 7, 2016
alexcrichton
added
the
T-libs
label
Aug 7, 2016
jonathandturner
added a commit
to jonathandturner/rust
that referenced
this issue
Aug 7, 2016
jonathandturner
added a commit
to jonathandturner/rust
that referenced
this issue
Aug 7, 2016
This comment has been minimized.
This comment has been minimized.
|
I wanted to use this today until I realized that it’s unstable. (I could use |
This comment has been minimized.
This comment has been minimized.
|
@rfcbot fcp merge Seems good to have consistency! |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
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. |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin I'm curious, when do you use ExactSizeIterator and have the opportunity to use this? |
This comment has been minimized.
This comment has been minimized.
|
When using a slice or vec iterator as input for a parser, |
This comment has been minimized.
This comment has been minimized.
|
Aha, that explains it for me: using a specific iterator type, not using ESI generically. This method is good, reinforces existing conventions. |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Nov 12, 2016
|
psst @alexcrichton, I wasn't able to add the |
alexcrichton
added
the
final-comment-period
label
Nov 12, 2016
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Nov 22, 2016
|
The final comment period is now complete. |
This comment has been minimized.
This comment has been minimized.
|
used in PR #37943 |
This comment has been minimized.
This comment has been minimized.
|
Here's a thought: Some iterators can implement a good is_empty() even if they can't do ESI or .len(). One example is |
aturon
referenced this issue
Dec 14, 2016
Merged
Library stabilizations/deprecations for 1.15 release #38369
This comment has been minimized.
This comment has been minimized.
|
@bluss Sorry I missed your comment when prepping the stabilization PR. My feeling is that these iterators can/should provide an inherent FWIW, it's also a longstanding desire on the lang side to have an API evolution path for splitting a trait into supertraits without breaking existing code. It's not guaranteed to happen, but that would allow us to split out |
This comment has been minimized.
This comment has been minimized.
|
I'm removing |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
Both points make sense. However, without further language improvements, it will be tricky to meet those goals and the original ergonomic goal at the same time. Ideally, Alternatively, we could add the |
This comment has been minimized.
This comment has been minimized.
|
don't we have a backdoor for adding methods like this? trait Iterator has the method .rposition() where Self: DoubleEndedIterator |
This comment has been minimized.
This comment has been minimized.
|
@bluss I may be missing something, but I don't see how that helps here. To clarify, the competing goals I see are:
I don't offhand see how the trick you mention helps here; maybe you can spell it out? It's worth noting that we could provide an |
This comment has been minimized.
This comment has been minimized.
|
It's easier said than done, apparently. trait Iterator can get a new method, something like: fn is_empty(&self) -> bool
where Self: IsEmptyIterator;which fixes the issue with having the method in the prelude. But to arrange the right blanket implementations for IsEmptyIterator does not seem to be possible, even with the specialization features that are in nightly now. |
alexcrichton
removed
the
final-comment-period
label
Dec 19, 2016
This comment has been minimized.
This comment has been minimized.
|
Did the |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin Yes, this ended up getting pulled from the stabilization PR and has been sitting idle since then. Needs someone to drive it to a conclusion. |
This comment has been minimized.
This comment has been minimized.
|
IMHO If people want to have more generality they can use the |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin While it currently isn't used internally in a generic context, I would like it so that an outside user can use the |
This comment has been minimized.
This comment has been minimized.
|
As I said, you can easily implement |
This comment has been minimized.
This comment has been minimized.
|
@clarcharr |
This comment has been minimized.
This comment has been minimized.
|
@ranma42 huh, I never realised. that seems like a bug to me |
This comment has been minimized.
This comment has been minimized.
|
Does |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
I mean, you could easily make
and
Although I guess that this is a bit out of the scope of the general discussion. My main point is that it's almost trivial to determine if an iterator is empty, and doesn't need a generic trait. We can deal with |
This comment has been minimized.
This comment has been minimized.
|
While the Peekable solution can serve as a trivial default, I still think that any default should be able to be overridden with a possibly faster form like with my previous example where the internal |
This comment has been minimized.
This comment has been minimized.
|
One thing that's unfortunate about |
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this and the consensus was to stabilize Iterator types that are not @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
|
Oops, it looks like rfcbot is not responding because a FCP was already completed in 2016. Anyone please make a stabilization PR, we’ll FCP there. |
SimonSapin
added
the
final-comment-period
label
Mar 28, 2018
This comment has been minimized.
This comment has been minimized.
|
(is the rfcbot code in a repo somewhere? because I'd be willing to take a look at that) |
This comment has been minimized.
This comment has been minimized.
|
As far as a proper method goes, I think that perhaps an |
This comment has been minimized.
This comment has been minimized.
|
(rfcbot is at https://github.com/anp/rfcbot-rs/) |
This comment has been minimized.
This comment has been minimized.
|
It still seems weird to have |
This comment has been minimized.
This comment has been minimized.
|
I can’t tell whether you’re arguing that |
This comment has been minimized.
This comment has been minimized.
|
On top of being able to express intent with I don't think |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin I'm arguing that I don't think inherent methods are a great option for |
This comment has been minimized.
This comment has been minimized.
|
I think that putting it on |
Centril
added
disposition-merge
finished-final-comment-period
and removed
final-comment-period
labels
May 24, 2018
This comment has been minimized.
This comment has been minimized.
|
Triage: What's barring this from stabilization? It's been on nightly for... 6 months now, I think? |
This comment has been minimized.
This comment has been minimized.
|
@Phlosioneer I don't think the situation has changed in the ~18 months since I wrote #35428 (comment) (More than that, since the "this should be on things that are not ESI" predates that, like #35428 (comment)) If you're looking at the labels, the finished-FCP is not for |
This comment has been minimized.
This comment has been minimized.
|
So we're not doing anything here because we haven't decided what to do about TrustedLen. And we haven't decided what to do about TrustedLen because no one has commented on it in 6 months. Cross-referencing #37572 To your earlier comment: TrustedLen defines no methods. ExactSizeIterator defines |
This comment has been minimized.
This comment has been minimized.
|
Also, we should fix the labels on this issue if they are incorrect. However, this issue is solely about stabilizing the is_empty function. The original call for RFC was specifically for is_empty. If we leave them as-is, this issue can easily be looked at as "If no one disagrees, is_empty will be merged." Particularly with the disposition-merge tag. |
frewsxcv commentedAug 6, 2016
Tracking issue for functionality introduced in #34357