Skip to content

Commit 9cd9da2

Browse files
committed
update documentation
1 parent e29b27b commit 9cd9da2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

library/core/src/iter/traits/double_ended.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ pub trait DoubleEndedIterator: Iterator {
101101
/// eagerly skip `n` elements starting from the back by calling [`next_back`] up
102102
/// to `n` times until [`None`] is encountered.
103103
///
104-
/// `advance_back_by(n)` will return `0` if the iterator successfully advances by
105-
/// `n` elements, or an usize `k` if [`None`] is encountered, where `k` is remaining number
106-
/// of steps that could not be advanced because the iterator ran out.
107-
/// Note that `k` is always less than `n`.
104+
/// `advance_back_by(n)` will return `Ok(())` if the iterator successfully advances by
105+
/// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered, where `k`
106+
/// is remaining number of steps that could not be advanced because the iterator ran out.
107+
/// If `self` is empty and `n` is non-zero, then this returns `Err(n)`.
108+
/// Otherwise, `k` is always less than `n`.
108109
///
109110
/// Calling `advance_back_by(0)` can do meaningful work, for example [`Flatten`] can advance its
110111
/// outer iterator until it finds an inner iterator that is not empty, which then often

library/core/src/iter/traits/iterator.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,11 @@ pub trait Iterator {
309309
/// This method will eagerly skip `n` elements by calling [`next`] up to `n`
310310
/// times until [`None`] is encountered.
311311
///
312-
/// `advance_by(n)` will return `0` if the iterator successfully advances by
313-
/// `n` elements, or an usize `k` if [`None`] is encountered, where `k` is remaining number
314-
/// of steps that could not be advanced because the iterator ran out.
315-
/// Note that `k` is always less than `n`.
312+
/// `advance_by(n)` will return `Ok(())` if the iterator successfully advances by
313+
/// `n` elements, or a `Err(NonZeroUsize)` with value `k` if [`None`] is encountered,
314+
/// where `k` is remaining number of steps that could not be advanced because the iterator ran out.
315+
/// If `self` is empty and `n` is non-zero, then this returns `Err(n)`.
316+
/// Otherwise, `k` is always less than `n`.
316317
///
317318
/// Calling `advance_by(0)` can do meaningful work, for example [`Flatten`]
318319
/// can advance its outer iterator until it finds an inner iterator that is not empty, which

0 commit comments

Comments
 (0)