From 77a3de3b95e74b50a1b62ac80ca90b3cf832f8d7 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Wed, 21 Aug 2013 13:58:00 -0700 Subject: [PATCH] Implement size_hint() on RangeInclusive --- src/libstd/iterator.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index c2d2e62a3c8..1af49ecd208 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -1592,6 +1592,21 @@ impl + Ord + Clone> Iterator for RangeInclusive { } } } + + #[inline] + fn size_hint(&self) -> (uint, Option) { + let (lo, hi) = self.range.size_hint(); + if self.done { + (lo, hi) + } else { + let lo = lo.saturating_add(1); + let hi = match hi { + Some(x) => x.checked_add(&1), + None => None + }; + (lo, hi) + } + } } impl + Integer + Ord + Clone> DoubleEndedIterator for RangeInclusive {