Skip to content

Commit

Permalink
iterator: UnfoldrIterator::new should have function argument last
Browse files Browse the repository at this point in the history
To match Rust conventions and enable use of `do` etc, make sure the
closure is the last argument to the `new` method.
  • Loading branch information
blake2-ppc authored and thestinger committed Jun 29, 2013
1 parent ee7307e commit b9cf6a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/libstd/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ impl<'self, A, St> UnfoldrIterator<'self, A, St> {
/// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the iterator
#[inline]
pub fn new<'a>(f: &'a fn(&mut St) -> Option<A>, initial_state: St)
pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
-> UnfoldrIterator<'a, A, St> {
UnfoldrIterator {
f: f,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ mod tests {
}
}

let mut it = UnfoldrIterator::new(count, 0);
let mut it = UnfoldrIterator::new(0, count);
let mut i = 0;
for it.advance |counted| {
assert_eq!(counted, i);
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/unfoldr-cross-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
}
}

let mut it = UnfoldrIterator::new(count, 0);
let mut it = UnfoldrIterator::new(0, count);
let mut i = 0;
for it.advance |counted| {
assert_eq!(counted, i);
Expand Down

0 comments on commit b9cf6a3

Please sign in to comment.