Skip to content

Commit 4853749

Browse files
committed
---
yaml --- r: 55226 b: refs/heads/snap-stage3 c: 8a28970 h: refs/heads/master v: v3
1 parent 34c793a commit 4853749

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 1bd318421e4fb4252074f2963ab77dddec7949ac
4+
refs/heads/snap-stage3: 8a28970ed36a9259b6cab2ad464f358c2d0bbb6f
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/iterator.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub trait Iterator<A> {
2929
///
3030
/// In the future these will be default methods instead of a utility trait.
3131
pub trait IteratorUtil<A> {
32-
fn chain(self, other: Self) -> ChainIterator<Self>;
32+
fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<Self, U>;
3333
fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<Self, U>;
3434
// FIXME: #5898: should be called map
3535
fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, Self>;
@@ -50,7 +50,7 @@ pub trait IteratorUtil<A> {
5050
/// In the future these will be default methods instead of a utility trait.
5151
impl<A, T: Iterator<A>> IteratorUtil<A> for T {
5252
#[inline(always)]
53-
fn chain(self, other: T) -> ChainIterator<T> {
53+
fn chain<U: Iterator<A>>(self, other: U) -> ChainIterator<T, U> {
5454
ChainIterator{a: self, b: other, flag: false}
5555
}
5656

@@ -115,13 +115,13 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
115115
}
116116
}
117117

118-
pub struct ChainIterator<T> {
118+
pub struct ChainIterator<T, U> {
119119
priv a: T,
120-
priv b: T,
120+
priv b: U,
121121
priv flag: bool
122122
}
123123

124-
impl<A, T: Iterator<A>> Iterator<A> for ChainIterator<T> {
124+
impl<A, T: Iterator<A>, U: Iterator<A>> Iterator<A> for ChainIterator<T, U> {
125125
#[inline]
126126
fn next(&mut self) -> Option<A> {
127127
if self.flag {
@@ -385,7 +385,7 @@ mod tests {
385385
#[test]
386386
fn test_iterator_chain() {
387387
let xs = [0u, 1, 2, 3, 4, 5];
388-
let ys = [30, 40, 50, 60];
388+
let ys = [30u, 40, 50, 60];
389389
let expected = [0, 1, 2, 3, 4, 5, 30, 40, 50, 60];
390390
let mut it = xs.iter().chain(ys.iter());
391391
let mut i = 0;
@@ -394,6 +394,15 @@ mod tests {
394394
i += 1;
395395
}
396396
assert_eq!(i, expected.len());
397+
398+
let ys = Counter::new(30u, 10).take(4);
399+
let mut it = xs.iter().transform(|&x| x).chain(ys);
400+
let mut i = 0;
401+
for it.advance |x: uint| {
402+
assert_eq!(x, expected[i]);
403+
i += 1;
404+
}
405+
assert_eq!(i, expected.len());
397406
}
398407

399408
#[test]

branches/snap-stage3/src/rt/rust_task.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@
175175
#define RED_ZONE_SIZE RZ_MAC_32
176176
#endif
177177

178-
#ifndef RED_ZONE_SIZE
179-
# error "Red zone not defined for this platform"
180-
#endif
181-
182178
struct frame_glue_fns {
183179
uintptr_t mark_glue_off;
184180
uintptr_t drop_glue_off;

0 commit comments

Comments
 (0)