File tree 2 files changed +6
-0
lines changed
2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change 140
140
//! call `next()` on your iterator, until it reaches `None`. Let's go over that
141
141
//! next.
142
142
//!
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
+ //!
143
148
//! # for Loops and IntoIterator
144
149
//!
145
150
//! 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 {
964
964
/// Creates an iterator that skips the first `n` elements.
965
965
///
966
966
/// After they have been consumed, the rest of the elements are yielded.
967
+ /// Rather than overriding this method directly, instead override the `nth` method.
967
968
///
968
969
/// # Examples
969
970
///
You can’t perform that action at this time.
0 commit comments