[−][src]Struct dispose::Disposable
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.
Implementations
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.
Safety
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]
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T: Debug + Dispose> Debug for Disposable<T>
[src]
impl<T: Dispose> Deref for Disposable<T>
[src]
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,
T: RefUnwindSafe,
impl<T> Send for Disposable<T> where
T: Send,
T: Send,
impl<T> Sync for Disposable<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Disposable<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Disposable<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<!> for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,