use std::any::Any; use std::fmt::{self, Debug}; use std::ops::{Deref, DerefMut}; use tokio::task::JoinHandle; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Opaque(pub T); impl Debug for Opaque { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ::fmt(&self.0, f) } } impl Deref for Opaque { type Target = T; fn deref(&self) -> &Self::Target { &self.0 } } impl DerefMut for Opaque { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } #[derive(Debug)] pub struct OwnedTask(pub JoinHandle<()>); impl Drop for OwnedTask { fn drop(&mut self) { self.0.abort(); } }