From 0891496898423bd03227a27492816ef56319d95c Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Sun, 16 Feb 2020 17:12:26 +0100 Subject: [PATCH 1/2] Improve documentation on iterators --- src/libcore/iter/mod.rs | 3 ++- src/libcore/iter/traits/exact_size.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 5fa9962f811c5..080b70c6368b2 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -43,7 +43,7 @@ //! are elements, and once they've all been exhausted, will return `None` to //! indicate that iteration is finished. Individual iterators may choose to //! resume iteration, and so calling [`next`] again may or may not eventually -//! start returning `Some(Item)` again at some point. +//! start returning `Some(Item)` again at some point (for example, see [`TryIter`]). //! //! [`Iterator`]'s full definition includes a number of other methods as well, //! but they are default methods, built on top of [`next`], and so you get @@ -56,6 +56,7 @@ //! [`Iterator`]: trait.Iterator.html //! [`next`]: trait.Iterator.html#tymethod.next //! [`Option`]: ../../std/option/enum.Option.html +//! [`TryIter`]: ../../std/sync/mpsc/struct.TryIter.html //! //! # The three forms of iteration //! diff --git a/src/libcore/iter/traits/exact_size.rs b/src/libcore/iter/traits/exact_size.rs index 4a7db348b1851..946c3f8582452 100644 --- a/src/libcore/iter/traits/exact_size.rs +++ b/src/libcore/iter/traits/exact_size.rs @@ -69,7 +69,8 @@ /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait ExactSizeIterator: Iterator { - /// Returns the exact number of times the iterator will iterate. + /// Returns the exact length of the iterator, which is the number of times + /// the iterator will return `Some(T)` before returning `None`. /// /// This method has a default implementation, so you usually should not /// implement it directly. However, if you can provide a more efficient From 0c82a5c1d35c84859ed2f88194858adae831d06d Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Mon, 2 Mar 2020 21:42:55 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- src/libcore/iter/traits/exact_size.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/traits/exact_size.rs b/src/libcore/iter/traits/exact_size.rs index 946c3f8582452..ad87d09588e3a 100644 --- a/src/libcore/iter/traits/exact_size.rs +++ b/src/libcore/iter/traits/exact_size.rs @@ -69,9 +69,10 @@ /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub trait ExactSizeIterator: Iterator { - /// Returns the exact length of the iterator, which is the number of times - /// the iterator will return `Some(T)` before returning `None`. + /// Returns the exact length of the iterator. /// + /// The implementation ensures that the iterator will return exactly `len()` + /// more times a `Some(T)` value, before returning `None`. /// This method has a default implementation, so you usually should not /// implement it directly. However, if you can provide a more efficient /// implementation, you can do so. See the [trait-level] docs for an