rollup merge of #17080 : treeman/issue-17066
This commit is contained in:
commit
b8dd7d5056
@ -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 {
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user