Skip to content

Commit 0ca1cae

Browse files
committed
doc: add Iterator::size_hint example
1 parent 7472886 commit 0ca1cae

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libcore/iter.rs

+7
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ pub trait Iterator {
9898
///
9999
/// An upper bound of `None` means either there is no known upper bound, or
100100
/// the upper bound does not fit within a `usize`.
101+
///
102+
/// # Examples
103+
///
104+
/// ```
105+
/// let it = (0..10).filter(|x| x % 2 == 0).chain(15..20);
106+
/// assert_eq!((5, Some(15)), it.size_hint());
107+
/// ```
101108
#[inline]
102109
#[stable(feature = "rust1", since = "1.0.0")]
103110
fn size_hint(&self) -> (usize, Option<usize>) { (0, None) }

0 commit comments

Comments
 (0)