This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
library/core/src/iter/traits Expand file tree Collapse file tree 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 {
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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments