about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev@gmail.com>2019-11-13 22:09:11 +0900
committerGitHub <noreply@github.com>2019-11-13 22:09:11 +0900
commite365d5aac614acd487a6cbdb23e9574948e6574a (patch)
treefd2ae096300278f56a5f32243cc9c29b93af7468
parent4ac230ad3d0cfc2340f134ead0001e93af119cd4 (diff)
parent23be25c82f517cb9ee5c4df57378e024d3c5b3eb (diff)
downloadrust-e365d5aac614acd487a6cbdb23e9574948e6574a.tar.gz
rust-e365d5aac614acd487a6cbdb23e9574948e6574a.zip
Rollup merge of #66094 - ArturKovacs:fix-count-doc, r=Dylan-DPC
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()`.
-rw-r--r--src/libcore/iter/traits/iterator.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs
index 7ffc8b3729c..b7a35568e3f 100644
--- a/src/libcore/iter/traits/iterator.rs
+++ b/src/libcore/iter/traits/iterator.rs
@@ -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
     ///