rust-lang / rust-lang/rust

Tracking Issue for `Option::into_flat_iter`

Open
#148,441 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue S-tracking-unimplemented T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

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: rust-lang/libs-team#626
  • Implementation: #148487
  • Final comment period (FCP)^1
  • Stabilization PR
Unresolved Questions
  • Should there be into_flat_iter and flat_iter or just into_flat_iter and as_ref/as_mut?

  • This is currently done as pub fn into_flat_iter<A>(self) -> OptionFlatten<A> where T: IntoIterator<IntoIter = A>, but do we want the A there or should it be pub fn into_flat_iter(self) -> OptionFlatten<<T as IntoIterator>::IntoIter>? see https://github.com/rust-lang/rust/pull/158741

  • Should this be unconditionally fused (since the iterator is holding an Option anyway), or only fused when the inner iterator is fused?

  • Should Result have this too, since it's also IntoIterator?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the option_flat_iter feature gate and review implementation PR #148487. Read the unresolved questions about method variants, fusion, and Result, then follow the stabilization process; done requires those questions to be resolved and the remaining FCP and stabilization steps completed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.