DropHandle

Struct DropHandle 

Source
pub struct DropHandle<T: DropMoveTypes>(/* private fields */);
Expand description

A wrapper of T::Outer that will drop by converting to T then dropping, rather than dropping the T::Outer.

The trouble with making drop be pass by move is that the self parameter may end up being dropped, creating infinite recursion. To avoid this, a DropHandle is passed to drop_move so that if it goes out of scope it will not create infinite recursion. This implements Deref and DerefMut for easy access to functions on T::Outer.

Implementations§

Source§

impl<T: DropMoveTypes> DropHandle<T>

Source

pub fn into_inner(self_: Self) -> T

Convert to the inner structure T.

This is an associated function so that will not conflict with any methods of T::Outer, which are accessible through Deref.

Source

pub fn into_outer(self_: Self) -> T::Outer

Convert to the outer structure T::Outer. Be careful when using this function, as it is easy to end up recursively calling drop on the output by accident, creating an infinite recursive loop.

This is an associated function so that will not conflict with any methods of T::Outer, which are accessible through Deref.

Trait Implementations§

Source§

impl<T: Debug + DropMoveTypes> Debug for DropHandle<T>
where T::Outer: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: DropMoveTypes> Deref for DropHandle<T>

Source§

type Target = <T as DropMoveTypes>::Outer

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T::Outer

Dereferences the value.
Source§

impl<T: DropMoveTypes> DerefMut for DropHandle<T>

Source§

fn deref_mut(&mut self) -> &mut T::Outer

Mutably dereferences the value.
Source§

impl<T: DropMoveTypes> Drop for DropHandle<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: DropMoveTypes> From<T> for DropHandle<T>

Source§

fn from(t: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> Freeze for DropHandle<T>
where <T as DropMoveTypes>::Outer: Freeze,

§

impl<T> RefUnwindSafe for DropHandle<T>

§

impl<T> Send for DropHandle<T>
where <T as DropMoveTypes>::Outer: Send,

§

impl<T> Sync for DropHandle<T>
where <T as DropMoveTypes>::Outer: Sync,

§

impl<T> Unpin for DropHandle<T>
where <T as DropMoveTypes>::Outer: Unpin,

§

impl<T> UnwindSafe for DropHandle<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.