Skip to content
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

Add example for iterator_flatten #105034

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

HintringerFabian
Copy link
Contributor

Adds an Example to iterator_flatten
Fixes #82687

@rustbot
Copy link
Collaborator

rustbot commented Nov 28, 2022

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 28, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 28, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@HintringerFabian
Copy link
Contributor Author

@rustbot label +A-docs

@rustbot rustbot added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Nov 29, 2022
@@ -1495,6 +1495,14 @@ pub trait Iterator {
/// assert_eq!(merged, "alphabetagamma");
/// ```
///
/// Flattening also works on other types like Option and Result:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not really specific to Option or Result though. It's that Flatten doesn't require Item: Iterator, it only needs Item: IntoIterator and Option/Result are types that implement that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think i do not really understand what you mean, should we not add this example should i change it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pointing out that "types like Option and Result" is very vague. It doesn't tell the reader which those types have in common so they can be used with Flatten. I don't have a particular improvement in mind, I was just pointing out the vagueness and how it actually works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we already document that "iterator of iterators or an iterator of things that can be turned into iterators" above -- I'm not sure another example is all that useful. I think we have enough examples personally for flatten.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is okay, although its placement is interrupting the "you can also rewrite this" example below, so we should move this down. For wording, perhaps:

Suggested change
/// Flattening also works on other types like Option and Result:
/// Flattening works on any `IntoIterator` type, including `Option` and `Result`:

Although we're not showing Result, so maybe do so too, or remove that part.

@Mark-Simulacrum
Copy link
Member

r? @cuviper since you seemed positive about the original bug report, maybe you have thoughts on how to phrase this well.

@rustbot rustbot assigned cuviper and unassigned Mark-Simulacrum Dec 5, 2022
Copy link
Member

@cuviper cuviper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your new example is still interrupting the two "alphabetagamma" examples -- please move yours down, and then I think this looks good!

@cuviper
Copy link
Member

cuviper commented Jan 3, 2023

@rustbot label -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2023
@HintringerFabian
Copy link
Contributor Author

@rustbot label +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2023
@cuviper
Copy link
Member

cuviper commented Jan 9, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 9, 2023

📌 Commit c364d32 has been approved by cuviper

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2023
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jan 9, 2023
…flatten_doc, r=cuviper

Add example for iterator_flatten

Adds an Example to iterator_flatten
Fixes rust-lang#82687
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 10, 2023
Rollup of 9 pull requests

Successful merges:

 - rust-lang#105034 (Add example for iterator_flatten)
 - rust-lang#105708 (Enable atomic cas for bpf targets)
 - rust-lang#106175 (Fix bad import suggestion with nested `use` tree)
 - rust-lang#106204 (No need to take opaques in `check_type_bounds`)
 - rust-lang#106387 (Revert "bootstrap: Get rid of `tail_args` in `stream_cargo`")
 - rust-lang#106636 (Accept old spelling of Fuchsia target triples)
 - rust-lang#106639 (update Miri)
 - rust-lang#106640 (update test for inductive canonical cycles)
 - rust-lang#106647 (rustdoc: merge common CSS for `a`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 002eccc into rust-lang:master Jan 10, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation of Iterator flatten() improvement
6 participants