Skip to content

Commit df16517

Browse files
committed
---
yaml --- r: 63037 b: refs/heads/snap-stage3 c: 32228f3 h: refs/heads/master i: 63035: 66e6f98 v: v3
1 parent 9eb2494 commit df16517

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
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: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 7e62ad6876550e9a7de7f5e6039707f4a8e15f9b
4+
refs/heads/snap-stage3: 32228f3d5781f93cc6f6419c1d6de33c5d1ba6c6
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ pub trait IteratorUtil<A> {
186186
/// assert_eq!(it.next().get(), &5);
187187
/// assert!(it.next().is_none());
188188
/// ~~~
189-
fn skip(self, n: uint) -> SkipIterator<Self>;
189+
fn skip(self, n: uint) -> SkipIterator<A, Self>;
190190

191191
/// Creates an iterator which yields the first `n` elements of this
192192
/// iterator, and then it will always return None.
@@ -203,7 +203,7 @@ pub trait IteratorUtil<A> {
203203
/// assert_eq!(it.next().get(), &3);
204204
/// assert!(it.next().is_none());
205205
/// ~~~
206-
fn take(self, n: uint) -> TakeIterator<Self>;
206+
fn take(self, n: uint) -> TakeIterator<A, Self>;
207207

208208
/// Creates a new iterator which behaves in a similar fashion to foldl.
209209
/// There is a state which is passed between each iteration and can be
@@ -386,12 +386,12 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
386386
}
387387

388388
#[inline(always)]
389-
fn skip(self, n: uint) -> SkipIterator<T> {
389+
fn skip(self, n: uint) -> SkipIterator<A, T> {
390390
SkipIterator{iter: self, n: n}
391391
}
392392

393393
#[inline(always)]
394-
fn take(self, n: uint) -> TakeIterator<T> {
394+
fn take(self, n: uint) -> TakeIterator<A, T> {
395395
TakeIterator{iter: self, n: n}
396396
}
397397

@@ -739,13 +739,14 @@ impl<'self, A, T: Iterator<A>> Iterator<A> for TakeWhileIterator<'self, A, T> {
739739
}
740740
}
741741

742-
/// An iterator which skips over `n` elements of `iter`
743-
pub struct SkipIterator<T> {
742+
/// An iterator which skips over `n` elements of `iter`.
743+
// FIXME #6967: Dummy A parameter to get around type inference bug
744+
pub struct SkipIterator<A, T> {
744745
priv iter: T,
745746
priv n: uint
746747
}
747748

748-
impl<A, T: Iterator<A>> Iterator<A> for SkipIterator<T> {
749+
impl<A, T: Iterator<A>> Iterator<A> for SkipIterator<A, T> {
749750
#[inline]
750751
fn next(&mut self) -> Option<A> {
751752
let mut next = self.iter.next();
@@ -772,12 +773,13 @@ impl<A, T: Iterator<A>> Iterator<A> for SkipIterator<T> {
772773
}
773774

774775
/// An iterator which only iterates over the first `n` iterations of `iter`.
775-
pub struct TakeIterator<T> {
776+
// FIXME #6967: Dummy A parameter to get around type inference bug
777+
pub struct TakeIterator<A, T> {
776778
priv iter: T,
777779
priv n: uint
778780
}
779781

780-
impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<T> {
782+
impl<A, T: Iterator<A>> Iterator<A> for TakeIterator<A, T> {
781783
#[inline]
782784
fn next(&mut self) -> Option<A> {
783785
let next = self.iter.next();
@@ -945,7 +947,7 @@ mod tests {
945947
let ys = [13, 15, 16, 17, 19, 20, 30];
946948
let mut it = xs.iter().skip(5);
947949
let mut i = 0;
948-
for it.advance |&x: &uint| {
950+
for it.advance |&x| {
949951
assert_eq!(x, ys[i]);
950952
i += 1;
951953
}
@@ -958,7 +960,7 @@ mod tests {
958960
let ys = [0u, 1, 2, 3, 5];
959961
let mut it = xs.iter().take(5);
960962
let mut i = 0;
961-
for it.advance |&x: &uint| {
963+
for it.advance |&x| {
962964
assert_eq!(x, ys[i]);
963965
i += 1;
964966
}

0 commit comments

Comments
 (0)