16 lines
289 B
Rust
16 lines
289 B
Rust
use tokio::task::AbortHandle;
|
|
|
|
pub struct DeadMansHandle(pub AbortHandle);
|
|
|
|
impl From<AbortHandle> for DeadMansHandle {
|
|
fn from(abort: AbortHandle) -> Self {
|
|
DeadMansHandle(abort)
|
|
}
|
|
}
|
|
|
|
impl Drop for DeadMansHandle {
|
|
fn drop(&mut self) {
|
|
self.0.abort();
|
|
}
|
|
}
|