From 0ca1caee93a29f2581b4696e71cb45cb79e32033 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Wed, 26 Aug 2015 22:45:32 +0200 Subject: [PATCH] doc: add Iterator::size_hint example --- src/libcore/iter.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index ee32999ba8fba..bbb2be3923b59 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) { (0, None) }