Skip to content

Commit

Permalink
slim down code branches
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jun 12, 2023
1 parent 6070083 commit 0d27cd8
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/future/join/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
let mut cx = Context::from_waker(this.wakers.get(i).unwrap());

// Poll the future
// SAFETY: we checked the future state was "pending"
// SAFETY: the future's state was "pending", so it's safe to poll
if let Poll::Ready(value) = unsafe {
fut.as_mut()
.map_unchecked_mut(|t| t.deref_mut())
Expand All @@ -113,11 +113,8 @@ where
this.items[i] = MaybeUninit::new(value);
this.state[i].set_ready();
*this.pending -= 1;
}

// If the state was changed from "pending" to "ready", drop the future.
if this.state[i].is_ready() {
// SAFETY: we're done with the future, drop in-place
// SAFETY: the future state has been changed to "ready" which
// means we'll no longer poll the future, so it's safe to drop
unsafe { ManuallyDrop::drop(fut.get_unchecked_mut()) };
}

Expand Down

0 comments on commit 0d27cd8

Please sign in to comment.