Skip to content

Commit

Permalink
Fix #135: check if Future has completed before polling it
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus-consoli committed May 16, 2023
1 parent c840597 commit 9430a9d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/future/try_join/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ macro_rules! impl_try_join_tuple {
assert!(!*this.done, "Futures must not be polled after completing");

for i in this.indexer.iter() {
if this.output_states[i].is_ready() {
continue;
}
utils::gen_conditions!(i, this, cx, poll, $(($mod_name::$F; $F, {
Poll::Ready(output) => match output {
Ok(output) => {
Expand Down Expand Up @@ -201,4 +204,20 @@ mod test {
assert_eq!(res.unwrap_err().to_string(), String::from("oh no"));
})
}

#[test]
fn issue_135_resume_after_completion() {
use futures_lite::future::yield_now;
futures_lite::future::block_on(async {
let ok = async { Ok::<_, ()>(()) };
let err = async {
yield_now().await;
Ok::<_, ()>(())
};

let res = (ok, err).try_join().await;

assert_eq!(res.unwrap(), ((), ()));
});
}
}

0 comments on commit 9430a9d

Please sign in to comment.