use tokio::task::JoinHandle;
pub(crate) struct AbortOnDrop(Option<JoinHandle<()>>);
impl AbortOnDrop {
pub(crate) fn new(handle: JoinHandle<()>) -> Self {
Self(Some(handle))
}
}
impl Drop for AbortOnDrop {
fn drop(&mut self) {
if let Some(handle) = self.0.take() {
handle.abort();
}
}
}