about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTshepang Lekhonkhobe <tshepang@gmail.com>2015-08-26 22:45:32 +0200
committerTshepang Lekhonkhobe <tshepang@gmail.com>2015-08-26 23:59:30 +0200
commit0ca1caee93a29f2581b4696e71cb45cb79e32033 (patch)
treec7ab312f3ad8cd5f72293732a0b44ba848598a5c
parent74728862339e156ecc10dd5a515f51bbaf9b4192 (diff)
downloadrust-0ca1caee93a29f2581b4696e71cb45cb79e32033.tar.gz
rust-0ca1caee93a29f2581b4696e71cb45cb79e32033.zip
doc: add Iterator::size_hint example
-rw-r--r--src/libcore/iter.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs
index ee32999ba8f..bbb2be3923b 100644
--- a/src/libcore/iter.rs
+++ b/src/libcore/iter.rs
@@ -98,6 +98,13 @@ pub trait Iterator {
     ///
     /// An upper bound of `None` means either there is no known upper bound, or
     /// the upper bound does not fit within a `usize`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let it = (0..10).filter(|x| x % 2 == 0).chain(15..20);
+    /// assert_eq!((5, Some(15)), it.size_hint());
+    /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     fn size_hint(&self) -> (usize, Option<usize>) { (0, None) }