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

Document implementing try_fold for iterators for internal iteration #62606

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@
//! next.
//!
//! Also note that `Iterator` provides a default implementation of methods such as `nth` and `fold`
//! which call `next` internally. However, it is also possible to write a custom implementation of
//! methods like `nth` and `fold` if an iterator can compute them more efficiently without calling
//! `next`.
//! which call `next` internally. Each of these methods delegates to the `try_fold` implementation.
//! So if you can produce a more efficient custom implementation of iterating over the entire
//! structure, then you can implement `try_fold` and get these other methods to use your iteration
//! strategy.
//!
//! # for Loops and IntoIterator
//!
Expand Down