You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Construct a FuturesUnordered, put n futures in it, call .into_iter().take(n-1) on it, and iterate the result.
Minimal example:
let _ = FuturesUnordered::from_iter(vec![ready(1), ready(2), ready(3), ready(4)])
.into_iter()
.take(3) // any number less than the number of futures in the collection, except zero
.count(); // or collect into another FuturesUnordered, or whatever.
Separately, while testing this, I found that if you only partially iterate that IntoIter type before dropping it, you get a different panic: future still here when dropping:
let _ = FuturesUnordered::from_iter(vec![ready(1), ready(2), ready(3), ready(4)])
.into_iter()
.take(3)
.next();
I also debugged this a bit and think I see what's going on. It looks like FuturesUnordered's IntoIter implementation does some brain surgery on the linked list while iterating which leaves it in a partially invalid state unless the iteration is fully completed. I'm preparing a possible fix.
The text was updated successfully, but these errors were encountered:
Construct a
FuturesUnordered
, putn
futures in it, call.into_iter().take(n-1)
on it, and iterate the result.Minimal example:
playground
Separately, while testing this, I found that if you only partially iterate that
IntoIter
type before dropping it, you get a different panic:future still here when dropping
:playground
I also debugged this a bit and think I see what's going on. It looks like FuturesUnordered's
IntoIter
implementation does some brain surgery on the linked list while iterating which leaves it in a partially invalid state unless the iteration is fully completed. I'm preparing a possible fix.The text was updated successfully, but these errors were encountered: