]> git.lizzy.rs Git - rust.git/blobdiff - src/libcore/iter/iterator.rs
Rollup merge of #41249 - GuillaumeGomez:rustdoc-render, r=steveklabnik,frewsxcv
[rust.git] / src / libcore / iter / iterator.rs
index fb98e43aa614b302f0ddf9707ebbaecde04585f1..8bf641e37fe467c2120defd6b1a90afc79b0674c 100644 (file)
@@ -518,13 +518,13 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
 
     /// Creates an iterator that both filters and maps.
     ///
-    /// The closure must return an [`Option<T>`]. `filter_map()` creates an
+    /// The closure must return an [`Option<T>`]. `filter_map` creates an
     /// iterator which calls this closure on each element. If the closure
     /// returns [`Some(element)`][`Some`], then that element is returned. If the
     /// closure returns [`None`], it will try again, and call the closure on the
     /// next element, seeing if it will return [`Some`].
     ///
-    /// Why `filter_map()` and not just [`filter()`].[`map`]? The key is in this
+    /// Why `filter_map` and not just [`filter`].[`map`]? The key is in this
     /// part:
     ///
     /// [`filter`]: #method.filter
@@ -534,7 +534,7 @@ fn filter<P>(self, predicate: P) -> Filter<Self, P> where
     ///
     /// In other words, it removes the [`Option<T>`] layer automatically. If your
     /// mapping is already returning an [`Option<T>`] and you want to skip over
-    /// [`None`]s, then `filter_map()` is much, much nicer to use.
+    /// [`None`]s, then `filter_map` is much, much nicer to use.
     ///
     /// # Examples
     ///
@@ -1532,14 +1532,18 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
     /// Stopping at the first `true`:
     ///
     /// ```
-    /// let a = [1, 2, 3];
+    /// let a = [1, 2, 3, 4];
     ///
     /// let mut iter = a.iter();
     ///
-    /// assert_eq!(iter.position(|&x| x == 2), Some(1));
+    /// assert_eq!(iter.position(|&x| x >= 2), Some(1));
     ///
     /// // we can still use `iter`, as there are more elements.
     /// assert_eq!(iter.next(), Some(&3));
+    ///
+    /// // The returned index depends on iterator state
+    /// assert_eq!(iter.position(|&x| x == 4), Some(0));
+    ///
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]