[][src]Struct dispose::Disposable

pub struct Disposable<T: Dispose>(_);

Wrapper for values implementing Dispose that provides a Drop implementation.

This struct will automatically consume its contents on drop using the provided Dispose implementation.

See this page for example usage.


impl<T: Dispose> Disposable<T>[src]

pub fn new(val: T) -> Self[src]

Construct a new Disposable instance, wrapping around val.

pub unsafe fn leak(this: Self) -> T[src]

Consume the wrapper, producing the contained value.


It is up to the user to ensure the value does not fall out of scope without being consumed.

The value can be safely re-inserted into a Disposable using Disposable::new to restore safe drop behavior, and it is recommended that the value is held by some container which consumes it on drop at all times. The intended use case for this function is transferring the value from one container to the other.

Trait Implementations

impl<T: Dispose> AsMut<T> for Disposable<T>[src]

impl<T: Dispose> AsRef<T> for Disposable<T>[src]

impl<T: Dispose> Borrow<T> for Disposable<T>[src]

impl<T: Dispose> BorrowMut<T> for Disposable<T>[src]

impl<T: Debug + Dispose> Debug for Disposable<T>[src]

impl<T: Dispose> Deref for Disposable<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T: Dispose> DerefMut for Disposable<T>[src]

impl<T: Dispose> Drop for Disposable<T>[src]

impl<T: Dispose> From<T> for Disposable<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Disposable<T> where
    T: RefUnwindSafe

impl<T> Send for Disposable<T> where
    T: Send

impl<T> Sync for Disposable<T> where
    T: Sync

impl<T> Unpin for Disposable<T> where
    T: Unpin

impl<T> UnwindSafe for Disposable<T> where
    T: UnwindSafe

Blanket Implementations

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

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

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

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.