File tree 2 files changed +10
-8
lines changed
library/core/src/iter/traits 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -101,10 +101,11 @@ pub trait DoubleEndedIterator: Iterator {
101
101
/// eagerly skip `n` elements starting from the back by calling [`next_back`] up
102
102
/// to `n` times until [`None`] is encountered.
103
103
///
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`.
108
109
///
109
110
/// Calling `advance_back_by(0)` can do meaningful work, for example [`Flatten`] can advance its
110
111
/// outer iterator until it finds an inner iterator that is not empty, which then often
Original file line number Diff line number Diff line change @@ -309,10 +309,11 @@ pub trait Iterator {
309
309
/// This method will eagerly skip `n` elements by calling [`next`] up to `n`
310
310
/// times until [`None`] is encountered.
311
311
///
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`.
316
317
///
317
318
/// Calling `advance_by(0)` can do meaningful work, for example [`Flatten`]
318
319
/// can advance its outer iterator until it finds an inner iterator that is not empty, which
You can’t perform that action at this time.
0 commit comments