pub trait TryTake<T>where
T: Sized,{
type Error;
// Required method
unsafe fn try_take(self) -> Result<T, Self::Error>;
}Expand description
Simple and safe ownership acquisition of sub-elements of a type.
This generalizes the Take trait to enable failure conditions for the
case of any acquisition failures.
Any caller of this trait that successfully acquires the underlying element must abide by the underlying requirements of that type for resource destruction.
Required Associated Types§
Required Methods§
sourceunsafe fn try_take(self) -> Result<T, Self::Error>
unsafe fn try_take(self) -> Result<T, Self::Error>
Attempts to take ownership of the underlying T element from this object.
§Safety
The caller of this function must ensure that they take responsibility of
the underlying T element if ownership is safely acquired. This may
require manually dropping or destroying the underlying resource in a safe
way.