Skip to content
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

Missing iterations #56883

Closed
samueltardieu opened this issue Dec 16, 2018 · 2 comments
Closed

Missing iterations #56883

samueltardieu opened this issue Dec 16, 2018 · 2 comments

Comments

@samueltardieu
Copy link
Contributor

The following code prints "foo" 4 times with stable and beta, but prints nothing with rustc 1.33.0-nightly (93c2f05 2018-12-15).

fn main() {
    std::iter::once(0).cycle().skip(1).take(4).for_each(|_| println!("foo"));
}

Replacing once() by something else or replacing for_each() with map() exhibits the same behaviour.

@bluss
Copy link
Member

bluss commented Dec 16, 2018

It looks like the try_fold impl for Cycle in commit fbe5aa5 is is not correct, this is probably the cause. PR #56630

@samueltardieu
Copy link
Contributor Author

Indeed, it looks like if you try to fold after you have just exhausted a copy of your original iterator, you are out of luck and will exit immediately with the initial value.

bors added a commit that referenced this issue Dec 17, 2018
Remove Cycle::try_fold override

Fixes #56883
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants