pub trait ExplicitDrop {
type ExplicitDropParam<'p>;
type ExplicitDropResult;
// Required method
fn explicit_drop<'p>(
self,
param: Self::ExplicitDropParam<'p>,
) -> Self::ExplicitDropResult;
}Expand description
Trait for a type that provides an explicit method for dropping its value.
Unlike the Drop trait, this traits method:
- Can take a parameter
- Can return something
- Consumes the value (instead of taking a
&mut)
Unfortunately there is no built-in way to ensure a type is explicitly
dropped. One workaround is for a type to also implement Drop, and have
that implementation validate that ExplicitDrop::explicit_drop was called.
Required Associated Types§
type ExplicitDropParam<'p>
type ExplicitDropResult
Required Methods§
fn explicit_drop<'p>( self, param: Self::ExplicitDropParam<'p>, ) -> Self::ExplicitDropResult
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".