File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 140140//! call `next()` on your iterator, until it reaches `None`. Let's go over that
141141//! next.
142142//!
143+ //! Also note that `Iterator` provides a default implementation of methods such as `nth` and `fold`
144+ //! which call `next` internally. However, it is also possible to write a custom implementation of
145+ //! methods like `nth` and `fold` if an iterator can compute them more efficiently without calling
146+ //! `next`.
147+ //!
143148//! # for Loops and IntoIterator
144149//!
145150//! Rust's `for` loop syntax is actually sugar for iterators. Here's a basic
Original file line number Diff line number Diff line change @@ -964,6 +964,7 @@ pub trait Iterator {
964964 /// Creates an iterator that skips the first `n` elements.
965965 ///
966966 /// After they have been consumed, the rest of the elements are yielded.
967+ /// Rather than overriding this method directly, instead override the `nth` method.
967968 ///
968969 /// # Examples
969970 ///
You can’t perform that action at this time.
0 commit comments