26 lines
686 B
Rust
26 lines
686 B
Rust
#[cfg(feature = "async-std-task")]
|
|
mod impl_task {
|
|
use async_std::task::JoinHandle;
|
|
|
|
use crate::{DropGuard, DropGuarded};
|
|
|
|
impl<T> DropGuarded for JoinHandle<T> {
|
|
#[inline]
|
|
fn cancel(self) {
|
|
let _ = JoinHandle::<T>::cancel(self);
|
|
}
|
|
}
|
|
|
|
impl<T> core::future::Future for DropGuard<JoinHandle<T>> {
|
|
type Output = T;
|
|
|
|
fn poll(
|
|
mut self: core::pin::Pin<&mut Self>,
|
|
cx: &mut core::task::Context<'_>,
|
|
) -> core::task::Poll<Self::Output> {
|
|
let handle = (*self).inner.as_mut().expect("can only be None in drop");
|
|
core::pin::Pin::new(handle).poll(cx)
|
|
}
|
|
}
|
|
}
|