Skip to content

Commit fa9b277

Browse files
committed
---
yaml --- r: 80795 b: refs/heads/try c: bf7587f h: refs/heads/master i: 80793: 3454a32 80791: fb3d9d0 v: v3
1 parent 2d20bd3 commit fa9b277

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: 1f961c74c4995b628ddb6c405295d78f9e79a849
5+
refs/heads/try: bf7587f5510d146c1f8bce4cb1ec10379d5b7d78
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libstd/iter.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,17 +1790,17 @@ pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A) -> R
17901790
RangeInclusive{range: range(start, stop), done: false}
17911791
}
17921792

1793-
impl<A: Add<A, A> + Ord + Clone> Iterator<A> for RangeInclusive<A> {
1793+
impl<A: Add<A, A> + Eq + Ord + Clone> Iterator<A> for RangeInclusive<A> {
17941794
#[inline]
17951795
fn next(&mut self) -> Option<A> {
17961796
match self.range.next() {
17971797
Some(x) => Some(x),
17981798
None => {
1799-
if self.done {
1800-
None
1801-
} else {
1799+
if !self.done && self.range.state == self.range.stop {
18021800
self.done = true;
18031801
Some(self.range.stop.clone())
1802+
} else {
1803+
None
18041804
}
18051805
}
18061806
}
@@ -2712,6 +2712,8 @@ mod tests {
27122712
fn test_range_inclusive() {
27132713
assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]);
27142714
assert_eq!(range_inclusive(0i, 5).invert().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]);
2715+
assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]);
2716+
assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]);
27152717
}
27162718

27172719
#[test]
@@ -2720,6 +2722,8 @@ mod tests {
27202722
assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]);
27212723
assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27222724
assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2725+
assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]);
2726+
assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]);
27232727
}
27242728

27252729
#[test]
@@ -2728,6 +2732,8 @@ mod tests {
27282732
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]);
27292733
assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27302734
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2735+
assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]);
2736+
assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]);
27312737
}
27322738

27332739
#[test]

0 commit comments

Comments
 (0)