Skip to content

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

Closed
@scottmcm

Description

@scottmcm

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

Metadata

Metadata

Assignees

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions