about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-22 22:31:27 -0700
committerbors <bors@rust-lang.org>2013-08-22 22:31:27 -0700
commit0688bde47f1288eec730a3e01dcbf825900db3c0 (patch)
tree2337668fa6fab93b5da85a51faed2376d3822c64 /src/libstd
parent9e1e15209129dad9d3bba90450a43ffb2505df14 (diff)
parent77a3de3b95e74b50a1b62ac80ca90b3cf832f8d7 (diff)
downloadrust-0688bde47f1288eec730a3e01dcbf825900db3c0.tar.gz
rust-0688bde47f1288eec730a3e01dcbf825900db3c0.zip
auto merge of #8671 : kballard/rust/range_inclusive-size-hint, r=thestinger
r? @thestinger
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/iterator.rs15
1 files changed, 15 insertions, 0 deletions
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<A: Add<A, A> + Ord + Clone> Iterator<A> for RangeInclusive<A> {
             }
         }
     }
+
+    #[inline]
+    fn size_hint(&self) -> (uint, Option<uint>) {
+        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<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclusive<A> {