Skip to content

Commit

Permalink
Simplify Fuse::poll to use a match expression instead of return (#2694
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Lucretiel authored and taiki-e committed Mar 11, 2023
1 parent b0d2c56 commit bc85d23
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions futures-util/src/future/future/fuse.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use core::pin::Pin;
use futures_core::future::{FusedFuture, Future};
use futures_core::ready;
use futures_core::task::{Context, Poll};
use pin_project_lite::pin_project;

Expand Down Expand Up @@ -81,13 +80,12 @@ impl<Fut: Future> Future for Fuse<Fut> {
type Output = Fut::Output;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Fut::Output> {
Poll::Ready(match self.as_mut().project().inner.as_pin_mut() {
Some(fut) => {
let output = ready!(fut.poll(cx));
match self.as_mut().project().inner.as_pin_mut() {
Some(fut) => fut.poll(cx).map(|output| {
self.project().inner.set(None);
output
}
None => return Poll::Pending,
})
}),
None => Poll::Pending,
}
}
}

0 comments on commit bc85d23

Please sign in to comment.