Skip to content

Commit

Permalink
Rollup merge of rust-lang#66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC
Browse files Browse the repository at this point in the history
Fix documentation for `Iterator::count()`.

The documentation of std::core::Iterator::count() stated that the number returned is the number of times `next` is called on the iterator. However this is not true as the number of times `next` is called is exactly one plus the number returned by `count()`.
  • Loading branch information
JohnTitor authored Nov 13, 2019
2 parents bfcf7f6 + 23be25c commit 7c666a7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/libcore/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ pub trait Iterator {

/// Consumes the iterator, counting the number of iterations and returning it.
///
/// This method will evaluate the iterator until its [`next`] returns
/// [`None`]. Once [`None`] is encountered, `count()` returns the number of
/// times it called [`next`].
/// This method will call [`next`] repeatedly until [`None`] is encountered,
/// returning the number of times it saw [`Some`]. Note that [`next`] has to be
/// called at least once even if the iterator does not have any elements.
///
/// [`next`]: #tymethod.next
/// [`None`]: ../../std/option/enum.Option.html#variant.None
/// [`Some`]: ../../std/option/enum.Option.html#variant.Some
///
/// # Overflow Behavior
///
Expand Down

0 comments on commit 7c666a7

Please sign in to comment.