]> 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 618edf48abd04370a43073368ac33bedb3129754..8bf641e37fe467c2120defd6b1a90afc79b0674c 100644 (file)
@@ -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")]