From 46abc1259801414a6f7206ede0bd579736097976 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sat, 10 Jul 2021 20:46:48 +0200 Subject: [PATCH] DOC: Add missing arguments to hypothetical code for step_by() --- library/core/src/iter/traits/iterator.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 8cb7aad28aa..16efd2f0eaf 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -333,21 +333,22 @@ pub trait Iterator { /// regardless of the step given. /// /// Note 2: The time at which ignored elements are pulled is not fixed. - /// `StepBy` behaves like the sequence `next(), nth(step-1), nth(step-1), …`, - /// but is also free to behave like the sequence - /// `advance_n_and_return_first(step), advance_n_and_return_first(step), …` + /// `StepBy` behaves like the sequence `self.next()`, `self.nth(step-1)`, + /// `self.nth(step-1)`, …, but is also free to behave like the sequence + /// `advance_n_and_return_first(&mut self, step)`, + /// `advance_n_and_return_first(&mut self, step)`, … /// Which way is used may change for some iterators for performance reasons. /// The second way will advance the iterator earlier and may consume more items. /// /// `advance_n_and_return_first` is the equivalent of: /// ``` - /// fn advance_n_and_return_first(iter: &mut I, total_step: usize) -> Option + /// fn advance_n_and_return_first(iter: &mut I, n: usize) -> Option /// where /// I: Iterator, /// { /// let next = iter.next(); - /// if total_step > 1 { - /// iter.nth(total_step-2); + /// if n > 1 { + /// iter.nth(n - 2); /// } /// next /// }