-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Chain iterator adapter changed behavior in nightly #71375
Comments
While the early drop is an observable change, I don't think that's directly your issue. You'd have the same problem if we just fused with a flag or a
So I feel the current approach is more consistent, fusing both iterators in either direction, but I do see how that breaks your use case.
We can do that, but I think double-ended chain will still be weird, and not quite the same weird as before. At first blush, I'd make forward methods only fuse the first iterator, and reverse methods only fuse the second iterator. If you have a mix of both directions, that would still make it possible to become totally fused, which is different than In defense of early dropping, I think not dropping can also cause hard-to-debug issues when one side is silently ignored. Consider the old |
That sounds reasonable, the main thing I would take into account is apart from which implementation is the most correct, the fact that this change in behavior is probably going to break things in subtle ways that are hard to debug. As you say I discovered this cause when the receiver dropped the sender got notified but i wasn't even using an mpsc channel but my own broadcast mpmc object so it just stopped receiving but the sender didn't notify me right away with an error cause other receivers where still alive which made it harder to figure out to the point where i had to modify the mpmc code to inspect the number of receivers still alive. |
Recently the
Chain
adapter has been changed to fuse the iterators it holds by destroying them, this introduces a subtle behavior change that is difficult to debug and as far as I see not documented.For example the following:
runs correctly on current stable (1.42) but panics in nightly cause the iterator is now fused so it can't be called anymore after it returns None for the first time.
stable: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a36e52425fa425eac3b7c24341b73d49
nightly: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4958f8dccb7594a0fa06a26ebc3d442b
Perhaps a possible solution would be to fuse the first iterator in the chain but not the second?
The text was updated successfully, but these errors were encountered: