rollup merge of #17080 : treeman/issue-17066

This commit is contained in:
Alex Crichton 2014-09-09 07:38:51 -07:00
commit b8dd7d5056
2 changed files with 2 additions and 2 deletions

View File

@ -2185,7 +2185,7 @@ pub type Iterate<'a, T> = Unfold<'a, T, IterateState<'a, T>>;
/// Creates a new iterator that produces an infinite sequence of
/// repeated applications of the given function `f`.
#[allow(visible_private_types)]
pub fn iterate<'a, T: Clone>(f: |T|: 'a -> T, seed: T) -> Iterate<'a, T> {
pub fn iterate<'a, T: Clone>(seed: T, f: |T|: 'a -> T) -> Iterate<'a, T> {
Unfold::new((f, Some(seed), true), |st| {
let &(ref mut f, ref mut val, ref mut first) = st;
if *first {

View File

@ -839,7 +839,7 @@ fn test_min_max_result() {
#[test]
fn test_iterate() {
let mut it = iterate(|x| x * 2, 1u);
let mut it = iterate(1u, |x| x * 2);
assert_eq!(it.next(), Some(1u));
assert_eq!(it.next(), Some(2u));
assert_eq!(it.next(), Some(4u));