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

FromIterator probably shouldn't say "rarely called explicitly" when it's in the prelude #90107

Closed
scottmcm opened this issue Oct 20, 2021 · 7 comments
Assignees
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@scottmcm
Copy link
Member

scottmcm commented Oct 20, 2021

The documentation for FromIterator https://doc.rust-lang.org/nightly/std/iter/trait.FromIterator.html says

FromIterator::from_iter() is rarely called explicitly, and is instead used through Iterator::collect() method. See Iterator::collect()’s documentation for more examples.

However, the trait is now in the rust_2021 prelude https://doc.rust-lang.org/nightly/core/prelude/rust_2021/index.html explicitly to allow it to be called more often.

This documentation should thus likely be updated to -- while still pointing at collect -- mention why one may wish to call it explicitly. Perhaps something like VecDeque::from_iter(0..100) would be a nice example.

One might also re-use some text from the RFC that added it to the prelude, https://rust-lang.github.io/rfcs/3114-prelude-2021.html#fromiterator

@scottmcm scottmcm added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Oct 20, 2021
@henrifrancois
Copy link

Can I take care of this?

@scottmcm
Copy link
Member Author

scottmcm commented Oct 23, 2021

@henrifrancois Absolutely!

You can use @rustbot claim to get the issue assigned to you.

@henrifrancois
Copy link

@rustbot claim

@JKAnderson409
Copy link

Hi @henrifrancois! I'd like to claim this issue if you're interested in releasing it.

@henrifrancois
Copy link

@rustbot unclaim. All yours @JKAnderson409

@JKAnderson409
Copy link

Thanks! @rustbot claim

m-ou-se added a commit to m-ou-se/rust that referenced this issue Mar 10, 2022
…ottmcm

Document new recommended use of `FromIterator::from_iter`

rust-lang#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Mar 10, 2022
…ottmcm

Document new recommended use of `FromIterator::from_iter`

rust-lang#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 10, 2022
…ottmcm

Document new recommended use of `FromIterator::from_iter`

rust-lang#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.
@JKAnderson409
Copy link

Closed by #94587

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 C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants