Skip to content

Commit b9cf6a3

Browse files
blake2-ppcthestinger
blake2-ppc
authored andcommitted
iterator: UnfoldrIterator::new should have function argument last
To match Rust conventions and enable use of `do` etc, make sure the closure is the last argument to the `new` method.
1 parent ee7307e commit b9cf6a3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libstd/iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ impl<'self, A, St> UnfoldrIterator<'self, A, St> {
983983
/// Creates a new iterator with the specified closure as the "iterator
984984
/// function" and an initial state to eventually pass to the iterator
985985
#[inline]
986-
pub fn new<'a>(f: &'a fn(&mut St) -> Option<A>, initial_state: St)
986+
pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
987987
-> UnfoldrIterator<'a, A, St> {
988988
UnfoldrIterator {
989989
f: f,
@@ -1174,7 +1174,7 @@ mod tests {
11741174
}
11751175
}
11761176

1177-
let mut it = UnfoldrIterator::new(count, 0);
1177+
let mut it = UnfoldrIterator::new(0, count);
11781178
let mut i = 0;
11791179
for it.advance |counted| {
11801180
assert_eq!(counted, i);

src/test/run-pass/unfoldr-cross-crate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() {
2424
}
2525
}
2626

27-
let mut it = UnfoldrIterator::new(count, 0);
27+
let mut it = UnfoldrIterator::new(0, count);
2828
let mut i = 0;
2929
for it.advance |counted| {
3030
assert_eq!(counted, i);

0 commit comments

Comments
 (0)