Rollup merge of #61237 - DevQps:expand-iterator-docs, r=Mark-Simulacrum
Updated the Iterator docs with information about overriding methods. # Description Updated the Iterator docs with information about overriding methods. closes #60223
This commit is contained in:
commit
a449bc3ad0
2 changed files with 6 additions and 0 deletions
|
@ -140,6 +140,11 @@
|
|||
//! call `next()` on your iterator, until it reaches `None`. Let's go over that
|
||||
//! 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`.
|
||||
//!
|
||||
//! # for Loops and IntoIterator
|
||||
//!
|
||||
//! Rust's `for` loop syntax is actually sugar for iterators. Here's a basic
|
||||
|
|
|
@ -964,6 +964,7 @@ pub trait Iterator {
|
|||
/// Creates an iterator that skips the first `n` elements.
|
||||
///
|
||||
/// After they have been consumed, the rest of the elements are yielded.
|
||||
/// Rather than overriding this method directly, instead override the `nth` method.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue