astd::convert

Trait TryTake

source
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§

source

type Error

The possible error type that might occur when trying to take ownership of the underlying T.

Required Methods§

source

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.

Implementors§

source§

impl<T, U> TryTake<T> for U
where U: Take<T>,