Skip to content

Commit e3f624d

Browse files
committed
---
yaml --- r: 63408 b: refs/heads/snap-stage3 c: fd8aa9a h: refs/heads/master v: v3
1 parent b0d3d9d commit e3f624d

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
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: ae23beb52f637b8c8640706ee8c6d2d4a5796bc8
4+
refs/heads/snap-stage3: fd8aa9afbd42cc6979c0b83690b32d27cc7afa78
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,8 @@ impl<'self, A, St> UnfoldrIterator<'self, A, St> {
816816
/// Creates a new iterator with the specified closure as the "iterator
817817
/// function" and an initial state to eventually pass to the iterator
818818
#[inline]
819-
pub fn new(f: &'self fn(&mut St) -> Option<A>, initial_state: St)
820-
-> UnfoldrIterator<'self, A, St> {
819+
pub fn new<'a>(f: &'a fn(&mut St) -> Option<A>, initial_state: St)
820+
-> UnfoldrIterator<'a, A, St> {
821821
UnfoldrIterator {
822822
f: f,
823823
state: initial_state
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use std::iterator::*;
12+
13+
// UnfoldrIterator had a bug with 'self that mean it didn't work
14+
// cross-crate
15+
16+
fn main() {
17+
fn count(st: &mut uint) -> Option<uint> {
18+
if *st < 10 {
19+
let ret = Some(*st);
20+
*st += 1;
21+
ret
22+
} else {
23+
None
24+
}
25+
}
26+
27+
let mut it = UnfoldrIterator::new(count, 0);
28+
let mut i = 0;
29+
for it.advance |counted| {
30+
assert_eq!(counted, i);
31+
i += 1;
32+
}
33+
assert_eq!(i, 10);
34+
}

0 commit comments

Comments
 (0)