1use futures::{
2 channel::oneshot,
3 task::{Context, Poll},
4};
5use std::pin::Pin;
6
7pub struct OneshotClosedFut<'a, T> {
9 sender: &'a mut oneshot::Sender<T>,
10}
11
12impl<'a, T> OneshotClosedFut<'a, T> {
13 pub fn new(sender: &'a mut oneshot::Sender<T>) -> Self {
15 Self { sender }
16 }
17}
18
19impl<T> futures::Future for OneshotClosedFut<'_, T> {
20 type Output = ();
21
22 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
23 match self.sender.poll_canceled(cx) {
25 Poll::Ready(()) => Poll::Ready(()), Poll::Pending => Poll::Pending, }
28 }
29}