pub struct DropGuard { inner: Option, } impl DropGuard { #[inline] pub fn unguard(mut self) -> T { self.inner.take().expect("only None in drop") } } pub trait DropGuarded { fn cancel(self); } impl DropGuard { #[inline] pub const fn new(guarded: T) -> Self { Self { inner: Some(guarded), } } } impl Drop for DropGuard { #[inline] fn drop(&mut self) { if let Some(inner) = self.inner.take() { inner.cancel(); } } } #[cfg(feature = "arbitrary")] mod impl_arbitrary; #[cfg(feature = "arbitrary")] pub use impl_arbitrary::ArbitraryDropGuard; #[cfg(feature = "async-std")] mod impl_async_std; #[cfg(feature = "tokio1")] mod impl_tokio1; #[cfg(feature = "triggered")] mod impl_triggered;