about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2016-07-06 19:13:05 -0400
committerGitHub <noreply@github.com>2016-07-06 19:13:05 -0400
commiteef10e6cfc3bf40b8470ad7c6ef939e4a385dbde (patch)
treea0482415aee442cbca2a460481b498ae2b1d8784 /src/libcore
parent155f0ec5c9ec09daccbf5a00f5707964922c3141 (diff)
parentdb26b3f5bcc49768a04867d5a21906f2bca4aa4a (diff)
downloadrust-eef10e6cfc3bf40b8470ad7c6ef939e4a385dbde.tar.gz
rust-eef10e6cfc3bf40b8470ad7c6ef939e4a385dbde.zip
Rollup merge of #33265 - tshepang:peek, r=steveklabnik
doc: some `peek` improvements
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/iter/mod.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs
index 3ebab266e2f..dffe9dee022 100644
--- a/src/libcore/iter/mod.rs
+++ b/src/libcore/iter/mod.rs
@@ -1198,17 +1198,15 @@ impl<I: ExactSizeIterator> ExactSizeIterator for Peekable<I> {}
 impl<I: Iterator> Peekable<I> {
     /// Returns a reference to the next() value without advancing the iterator.
     ///
-    /// The `peek()` method will return the value that a call to [`next()`] would
-    /// return, but does not advance the iterator. Like [`next()`], if there is
-    /// a value, it's wrapped in a `Some(T)`, but if the iterator is over, it
-    /// will return `None`.
+    /// Like [`next()`], if there is a value, it is wrapped in a `Some(T)`.
+    /// But if the iteration is over, `None` is returned.
     ///
     /// [`next()`]: trait.Iterator.html#tymethod.next
     ///
-    /// Because `peek()` returns reference, and many iterators iterate over
-    /// references, this leads to a possibly confusing situation where the
+    /// Because `peek()` returns a reference, and many iterators iterate over
+    /// references, there can be a possibly confusing situation where the
     /// return value is a double reference. You can see this effect in the
-    /// examples below, with `&&i32`.
+    /// examples below.
     ///
     /// # Examples
     ///
@@ -1225,13 +1223,13 @@ impl<I: Iterator> Peekable<I> {
     ///
     /// assert_eq!(iter.next(), Some(&2));
     ///
-    /// // we can peek() multiple times, the iterator won't advance
+    /// // The iterator does not advance even if we `peek` multiple times
     /// assert_eq!(iter.peek(), Some(&&3));
     /// assert_eq!(iter.peek(), Some(&&3));
     ///
     /// assert_eq!(iter.next(), Some(&3));
     ///
-    /// // after the iterator is finished, so is peek()
+    /// // After the iterator is finished, so is `peek()`
     /// assert_eq!(iter.peek(), None);
     /// assert_eq!(iter.next(), None);
     /// ```
@@ -1263,10 +1261,10 @@ impl<I: Iterator> Peekable<I> {
     ///
     /// let mut iter = xs.iter().peekable();
     ///
-    /// // there are still elements to iterate over
+    /// // There are still elements to iterate over
     /// assert_eq!(iter.is_empty(), false);
     ///
-    /// // let's consume the iterator
+    /// // Let's consume the iterator
     /// iter.next();
     /// iter.next();
     /// iter.next();