Skip to content

Commit f35a648

Browse files
committed
---
yaml --- r: 141017 b: refs/heads/try2 c: 883d583 h: refs/heads/master i: 141015: 2a6c5cd v: v3
1 parent 909c4c4 commit f35a648

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ea8a55b821460ef7b3b58052f99673674fca8f96
8+
refs/heads/try2: 883d583faa9f33e69dce4b913f47a2d09e8b584d
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/iterator.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub trait IteratorUtil<A> {
4747
fn advance(&mut self, f: &fn(A) -> bool);
4848
#[cfg(not(stage0))]
4949
fn advance(&mut self, f: &fn(A) -> bool) -> bool;
50-
fn to_vec(self) -> ~[A];
50+
fn to_vec(&mut self) -> ~[A];
5151
fn nth(&mut self, n: uint) -> Option<A>;
5252
fn last(&mut self) -> Option<A>;
5353
fn fold<B>(&mut self, start: B, f: &fn(B, A) -> B) -> B;
@@ -147,11 +147,8 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
147147
}
148148

149149
#[inline(always)]
150-
fn to_vec(self) -> ~[A] {
151-
let mut v = ~[];
152-
let mut it = self;
153-
for it.advance() |x| { v.push(x); }
154-
return v;
150+
fn to_vec(&mut self) -> ~[A] {
151+
iter::to_vec::<A>(|f| self.advance(f))
155152
}
156153

157154
/// Return the `n`th item yielded by an iterator.
@@ -563,7 +560,7 @@ mod tests {
563560

564561
#[test]
565562
fn test_filter_map() {
566-
let it = Counter::new(0u, 1u).take(10)
563+
let mut it = Counter::new(0u, 1u).take(10)
567564
.filter_map(|x: uint| if x.is_even() { Some(x*x) } else { None });
568565
assert_eq!(it.to_vec(), ~[0*0, 2*2, 4*4, 6*6, 8*8]);
569566
}

0 commit comments

Comments
 (0)