about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Burka <durka42@gmail.com>2016-09-11 01:55:15 +0000
committerAlex Burka <durka42@gmail.com>2016-09-12 17:06:53 +0000
commitbd1ae637f8c9ecb94614831c4e6642d09f508dfb (patch)
treebe941eb7aecbe1d21ff10cb8b79393e51da1d744
parent1fca1ab0e7be574022b2d229f0a6ad9bd580d1bf (diff)
downloadrust-bd1ae637f8c9ecb94614831c4e6642d09f508dfb.tar.gz
rust-bd1ae637f8c9ecb94614831c4e6642d09f508dfb.zip
remove ExactSizeIterator from RangeInclusive<u/isize>
-rw-r--r--src/libcore/iter/range.rs11
-rw-r--r--src/test/run-pass/range_inclusive.rs2
2 files changed, 10 insertions, 3 deletions
diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs
index 66d05d81d80..38afcb6a65e 100644
--- a/src/libcore/iter/range.rs
+++ b/src/libcore/iter/range.rs
@@ -466,7 +466,11 @@ macro_rules! range_exact_iter_impl {
     ($($t:ty)*) => ($(
         #[stable(feature = "rust1", since = "1.0.0")]
         impl ExactSizeIterator for ops::Range<$t> { }
+    )*)
+}
 
+macro_rules! range_incl_exact_iter_impl {
+    ($($t:ty)*) => ($(
         #[unstable(feature = "inclusive_range",
                    reason = "recently added, follows RFC",
                    issue = "28237")]
@@ -500,9 +504,12 @@ impl<A: Step> Iterator for ops::Range<A> where
     }
 }
 
-// Ranges of u64 and i64 are excluded because they cannot guarantee having
-// a length <= usize::MAX, which is required by ExactSizeIterator.
+// These macros generate `ExactSizeIterator` impls for various range types.
+// Range<{u,i}64> and RangeInclusive<{u,i}{32,64,size}> are excluded
+// because they cannot guarantee having a length <= usize::MAX, which is
+// required by ExactSizeIterator.
 range_exact_iter_impl!(usize u8 u16 u32 isize i8 i16 i32);
+range_incl_exact_iter_impl!(u8 u16 i8 i16);
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A: Step + Clone> DoubleEndedIterator for ops::Range<A> where
diff --git a/src/test/run-pass/range_inclusive.rs b/src/test/run-pass/range_inclusive.rs
index aaf129e7b8e..cfa9f6e36e9 100644
--- a/src/test/run-pass/range_inclusive.rs
+++ b/src/test/run-pass/range_inclusive.rs
@@ -75,7 +75,7 @@ pub fn main() {
 
     // test the size hints and emptying
     let mut long = 0...255u8;
-    let mut short = 42...42;
+    let mut short = 42...42u8;
     assert_eq!(long.size_hint(), (256, Some(256)));
     assert_eq!(short.size_hint(), (1, Some(1)));
     long.next();