diff options
| author | The 8472 <git@infinite-source.de> | 2023-03-13 20:16:43 +0100 |
|---|---|---|
| committer | The 8472 <git@infinite-source.de> | 2023-03-27 16:03:30 +0200 |
| commit | 9cd9da2cd1c365791c7bf41be5759ebc34180aa0 (patch) | |
| tree | 75842f804dd5ad0e3f1883e8a815025688abb019 | |
| parent | e29b27b4a4c6b6fc80e38d2747c8076a59475c03 (diff) | |
| download | rust-9cd9da2cd1c365791c7bf41be5759ebc34180aa0.tar.gz rust-9cd9da2cd1c365791c7bf41be5759ebc34180aa0.zip | |
update documentation
| -rw-r--r-- | library/core/src/iter/traits/double_ended.rs | 9 | ||||
| -rw-r--r-- | library/core/src/iter/traits/iterator.rs | 9 |
2 files changed, 10 insertions, 8 deletions
diff --git a/library/core/src/iter/traits/double_ended.rs b/library/core/src/iter/traits/double_ended.rs index 182b365b030..d82ecb698dd 100644 --- a/library/core/src/iter/traits/double_ended.rs +++ b/library/core/src/iter/traits/double_ended.rs @@ -101,10 +101,11 @@ pub trait DoubleEndedIterator: Iterator { /// eagerly skip `n` elements starting from the back by calling [`next_back`] up /// to `n` times until [`None`] is encountered. /// - /// `advance_back_by(n)` will return `0` if the iterator successfully advances by - /// `n` elements, or an usize `k` if [`None`] is encountered, where `k` is remaining number - /// of steps that could not be advanced because the iterator ran out. - /// Note that `k` is always less than `n`. + /// `advance_back_by(n)` will return `Ok(())` if the iterator successfully advances by + /// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered, where `k` + /// is remaining number of steps that could not be advanced because the iterator ran out. + /// If `self` is empty and `n` is non-zero, then this returns `Err(n)`. + /// Otherwise, `k` is always less than `n`. /// /// Calling `advance_back_by(0)` can do meaningful work, for example [`Flatten`] can advance its /// outer iterator until it finds an inner iterator that is not empty, which then often diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 5a1ee80f796..080330fa41e 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -309,10 +309,11 @@ pub trait Iterator { /// This method will eagerly skip `n` elements by calling [`next`] up to `n` /// times until [`None`] is encountered. /// - /// `advance_by(n)` will return `0` if the iterator successfully advances by - /// `n` elements, or an usize `k` if [`None`] is encountered, where `k` is remaining number - /// of steps that could not be advanced because the iterator ran out. - /// Note that `k` is always less than `n`. + /// `advance_by(n)` will return `Ok(())` if the iterator successfully advances by + /// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered, + /// where `k` is remaining number of steps that could not be advanced because the iterator ran out. + /// If `self` is empty and `n` is non-zero, then this returns `Err(n)`. + /// Otherwise, `k` is always less than `n`. /// /// Calling `advance_by(0)` can do meaningful work, for example [`Flatten`] /// can advance its outer iterator until it finds an inner iterator that is not empty, which |
