Skip to content

iterator: UnfoldrIterator::new should have function argument last #7450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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