Uh oh!
There was an error while loading. Please reload this page.
Stabilize FusedIterator - #47463
Conversation
rust-highfive
commented
Jan 15, 2018
r? @shepmaster (rust_highfive has picked a reviewer for you, use r? to override) |
sfackler
commented
Jan 15, 2018
This only exists for specialization right? Are we comfortable stabilizing these kinds of things before specialization itself? |
bluss
commented
Jan 15, 2018
That is the right question and I think FusedIterator does not depend on any controversial or hard part of specialization, so it seems ok. meanwhile I can't understand what tidy wants me to fix.. |
644f111 to
96e6103Comparebluss
commented
Jan 17, 2018
rebased to fix newer FusedIterator impls. That should fix tidy. |
sfackler
commented
Jan 18, 2018
The worst case is that this becomes a slightly weird/useless trait if we have to do something drastic like roll back specialization entirely. Seems okay to stabilize I guess. @rfcbot fcp merge |
Team member @sfackler 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. |
withoutboats
commented
Jan 18, 2018
Maybe I don't understand how it is used, but isn't one of the main use cases essentially something like this: traitFuse{typeFused;fnfuse(self) -> Self::Fused;}impl<T:Iterator>FuseforT{ ... }impl<T:FusedIterator>FuseforT{ ... }This would involve specializing the associated type, which is one of the trickiest parts of specialization (because it could result in different impl instantiations at typeck time from trans time). |
bluss
commented
Jan 18, 2018
The main use is in .fused and it is method specialization only, no associated types. Your example is interesting in itself but not what std is using now. |
bluss
commented
Jan 18, 2018
In Iterator::fuse. |
alexcrichton
commented
Jan 18, 2018
Is there perhaps a "banner use case" for this trait right now? I've personally only ever seen it as a pretty niche optimization that almost never comes up in practice (I can't remember the last time I used I'm also pretty worried about the specialization here. If we roll it back I feel like it would be a breaking change with a trait like this. Users would use this trait only for the performance improvement (right?) and if we break that then we're effectively breaking the trait? |
@alexcrichton .fuse() is something itertools uses a lot, so it's typical of that use case -- when we build upon iterators completely generically. For example, The use case would be to implement the marker trait As a small nice thing, having I think the specialization that is assumed here really is the basics and it was my impression that we are pretty certain to ship that part sooner rather than later. |
alexcrichton
commented
Jan 19, 2018
@bluss ok cool thanks for the info! To clarify as well, would you consider it a breaking change if we end up later neutering the trait to not actually do anything (if specialization is removed)? The state of specialization AFAIK is sort of "continuously in the air" where there's always a few known soundness holes with no known fixes, but there's a big chunk that's known as highly desirable and safe but unknown how to stabilize. |
bluss
commented
Jan 19, 2018
No, I can't see how it is a breaking change. We would have performance setbacks all over libcore without spec, fuse is not among the most important, and I imagine we would want other mechanisms to get the same effects. There is a risk that the trait becomes obsolete then yes if the new mechanism is not trait based. |
alexcrichton
commented
Jan 19, 2018
Hm ok, if you're ok with that outcome so am I! |
kennytm
commented
Jan 31, 2018
Triage ping, ticky boxes for you @BurntSushi! |
emilyalbini
commented
Feb 5, 2018
@BurntSushi there is a nice checkbox in #47463 (comment) waiting for you! |
| } | ||
| #[unstable(feature = "fused", issue = "35602")] | ||
| #[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
DecodeUtf8 is still unstable so this should be #[unstable(feature = "decode_utf8", issue = "33906")].
| } | ||
| #[unstable(feature = "fused", issue = "35602")] | ||
| #[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
RangeInclusive is still unstable so this should be #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")].
| } | ||
| #[unstable(feature = "fused", issue = "35602")] | ||
| #[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
ExactChunks is still unstable so this should be #[unstable(feature = "exact_chunks", issue = "47115")].
| } | ||
| #[unstable(feature = "fused", issue = "35602")] | ||
| #[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
ExactChunksMut is still unstable so this should be #[unstable(feature = "exact_chunks", issue = "47115")].
| } | ||
| #[unstable(feature = "fused", issue = "35602")] | ||
| #[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
Utf16Encoder is still unstable so this line can be removed.
| } | ||
| //#[unstable(feature = "fused", issue = "35602")] | ||
| //#[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
RSplit is still unstable so this line can just be removed.
| } | ||
| //#[unstable(feature = "fused", issue = "35602")] | ||
| //#[stable(feature = "fused", since = "1.25.0")] |
There was a problem hiding this comment.
RSplitMut is still unstable so this line can just be removed.
rfcbot
commented
Feb 6, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔 |
alexcrichton
commented
Feb 6, 2018
bors
commented
Mar 5, 2018
⌛ Testing commit c7c23fe with merge d9455e8a7f272c0fec238dbba7af39b560dbf2f0... |
bors
commented
Mar 6, 2018
💔 Test failed - status-travis |
alexcrichton
commented
Mar 6, 2018
@bors: retry
|
bors
commented
Mar 6, 2018
⌛ Testing commit c7c23fe with merge 386cd00ba6fa150f64cdae31223f5a648fcf08c4... |
bors
commented
Mar 6, 2018
💔 Test failed - status-appveyor |
kennytm
commented
Mar 6, 2018
Stabilize FusedIterator FusedIterator is a marker trait that promises that the implementing iterator continues to return `None` from `.next()` once it has returned `None` once (and/or `.next_back()`, if implemented). The effects of FusedIterator are already widely available through `.fuse()`, but with stable `FusedIterator`, stable Rust users can implement this trait for their iterators when appropriate. Closesrust-lang#35602
bluss
commented
Mar 7, 2018
Aw, that's quite the fight with bors. You pushed it over the finish line @alexcrichton, thank you! |
…r=bluss Unstabilize FusedIterator for Flatten since Flatten is unstable PR rust-lang#47463 made `impl<I, U> FusedIterator for Flatten<I>` stable but shouldn't have since `Flatten` is still unstable. This PR makes the impl unstable again.
FusedIterator is a marker trait that promises that the implementing
iterator continues to return
Nonefrom.next()once it has returnedNoneonce (and/or.next_back(), if implemented).The effects of FusedIterator are already widely available through
.fuse(), but with stableFusedIterator, stable Rust users canimplement this trait for their iterators when appropriate.
Closes#35602