-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
[WIP] Implement FusedIterator #32999
Conversation
This trait can be used to avoid the overhead of a fuse wrapper (which is pretty high).
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
#[stable(feature = "rust1", since = "1.0.0")] | ||
impl<I> Iterator for Fuse<I> where I: Iterator { | ||
type Item = <I as Iterator>::Item; | ||
|
||
#[inline] | ||
fn next(&mut self) -> Option<<I as Iterator>::Item> { | ||
default fn next(&mut self) -> Option<<I as Iterator>::Item> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC #32586 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm mistaken, that doesn't apply here (yet) because we don't have the lattice rule. That is, a specialized implementation would have to have the bound I: FusedIterator + Something
and the implementation on FusedIterator
isn't marked default
. However, that's a good point. I'll make a note of this on the specialization issue.
I think the RFC link is to the wrong repo, should be rust-lang/rfcs#1581 |
@hexsel github auto-linking... thanks. |
@Stebalien Here's another way this could be done: https://play.rust-lang.org/?gist=1c74c425ab7f916b691053348b27cb61&version=nightly&backtrace=0. |
☔ The latest upstream changes (presumably #33079) made this pull request unmergeable. Please resolve the merge conflicts. |
@apasel422 that certainly gets rid of the unnecessary |
Closing due to inactivity, but feel free to reopen once the RFC is accepted! |
Pending RFC rust-lang/rfcs#1581
Only implements FusedIterator for core.
/cc @bluss, @apasel422