about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorSebastian Hahn <sebastian@torproject.org>2017-04-11 14:51:56 +0200
committerSebastian Hahn <sebastian@torproject.org>2017-04-11 19:39:58 +0200
commit316af6082c8c23615cc54302ee7efa0811bbabe7 (patch)
treefe81a68462edc3ead3c55b07a3769dfb24e0efe5 /src/libcore
parent6edc59685382d3ec0b6b89b05897a22a597c48a1 (diff)
Clarify Iterator::position doc
Extend the example a little bit to show behaviour better.
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/iter/iterator.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs
index 618edf48abd..8bf641e37fe 100644
--- a/src/libcore/iter/iterator.rs
+++ b/src/libcore/iter/iterator.rs
@@ -1532,14 +1532,18 @@ pub trait Iterator {
     /// 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")]