From 964ff0385b6096c9c7a1a756c072e795715ded6a Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Thu, 11 Jul 2019 20:01:29 -0700 Subject: [PATCH 1/2] Document implementing `try_fold` for iterators for internal iteration --- src/libcore/iter/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 6eccb9d1ea86d..c92b465bdba68 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -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` implemantation. +//! 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 //! From 6c8dbec35d2c35bc95962511c90cb97fc3735728 Mon Sep 17 00:00:00 2001 From: Chris Gregory Date: Thu, 11 Jul 2019 20:03:40 -0700 Subject: [PATCH 2/2] Fix typo --- src/libcore/iter/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index c92b465bdba68..c752a9212c144 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -141,7 +141,7 @@ //! next. //! //! Also note that `Iterator` provides a default implementation of methods such as `nth` and `fold` -//! which call `next` internally. Each of these methods delegates to the `try_fold` implemantation. +//! 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.