actor12/
drop.rs

1use std::ops::Deref;
2use std::ops::DerefMut;
3
4use tokio::task::JoinHandle;
5
6#[derive(Debug)]
7pub struct DropHandle<T>(pub JoinHandle<T>);
8
9impl<T> DropHandle<T> {
10	pub fn abort(&self) {
11		self.0.abort();
12	}
13}
14
15impl<T> Deref for DropHandle<T> {
16	type Target = JoinHandle<T>;
17	fn deref(&self) -> &Self::Target {
18		&self.0
19	}
20}
21
22impl<T> DerefMut for DropHandle<T> {
23	fn deref_mut(&mut self) -> &mut Self::Target {
24		&mut self.0
25	}
26}
27
28impl<T> Drop for DropHandle<T> {
29	fn drop(&mut self) {
30		self.0.abort()
31	}
32}