Repository navigation
Description
Feature gate: #![feature(option_flat_iter)]
This is a tracking issue for Option::(into_)flat_iter, methods for getting iterators out of Options.
Public API
impl<T> Option<T> where T: IntoIterator {
pub fn into_flat_iter(self) -> OptionFlatten<<T as IntoIterator>::IntoIter>;
}Steps / History
(Remember to update the S-tracking-* label when checking boxes.)
- ACP:
Option::map_iter()to create an iterator fromOptionlibs-team#626 - Implementation: add Option::into_flat_iter #148487
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
-
Should there be
into_flat_iterandflat_iteror justinto_flat_iterandas_ref/as_mut? -
This is currently done assee Simplifypub fn into_flat_iter<A>(self) -> OptionFlatten<A> where T: IntoIterator<IntoIter = A>, but do we want theAthere or should it bepub fn into_flat_iter(self) -> OptionFlatten<<T as IntoIterator>::IntoIter>?Option::into_flat_itersignature #158741 -
Should this be unconditionally fused (since the iterator is holding an
Optionanyway), or only fused when the inner iterator is fused? -
Should
Resulthave this too, since it's alsoIntoIterator?
Activity
Qelxiros commentedon Nov 3, 2025
@ChayimFriedman2 Do you still want to implement this? If not, I'm happy to try. Regardless, rust-lang/libs-team#626 should be closed.
zachs18 commentedon Nov 3, 2025
(for the "Unresolved Questions" section):
Should the by-ref version be spelled as
opt.as_ref().into_flat_iter()instead of having a dedicated method?Alternately, should there be a by-mut-ref method (e.g.
flat_iter_mut), instead of spelling it asopt.as_mut().into_flat_iter()?ChayimFriedman2 commentedon Nov 3, 2025
@Qelxiros Feel free to take this, but I was waiting an answer to rust-lang/libs-team#626 (comment).
[-]Tracking Issue for `Option::(into_)flat_iter`[/-][+]Tracking Issue for `Option::into_flat_iter`[/+]Rollup merge of rust-lang#148487 - Qelxiros:148441-option-into-flat-i…
Rollup merge of rust-lang#148487 - Qelxiros:148441-option-into-flat-i…
Unrolled build for #148487
Rollup merge of #148487 - Qelxiros:148441-option-into-flat-iter, r=sc…
Rollup merge of #148487 - Qelxiros:148441-option-into-flat-iter, r=sc…
Rollup merge of rust-lang#148487 - Qelxiros:148441-option-into-flat-i…
Rollup merge of #148487 - Qelxiros:148441-option-into-flat-iter, r=sc…
Rollup merge of #148487 - Qelxiros:148441-option-into-flat-iter, r=sc…
camsteffen commentedon Jul 2, 2026
Maybe unresolved question: If the performance benefits can be supplanted with specialization on existing methods, does this method(s) still carry its weight?
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Rollup merge of rust-lang#158741 - WaffleLapkin:into_flat_iter_noa, r…
Unrolled build for #158741
Rollup merge of #158741 - WaffleLapkin:into_flat_iter_noa, r=hanna-kr…
Rollup merge of #158741 - WaffleLapkin:into_flat_iter_noa, r=hanna-kr…
aqrln commentedon Aug 23, 2026
#158741 already simplified the signature, and there's a discussion in that PR with justification (being able to turbofish the iterator type is normally not very useful, it should be easier to name the iterable if type annotations are necessary). The second unresolved question should probably be marked as resolved now.