[−][src]Struct phantomdrop::PhantomDrop
When dropped, the included function is ran with the argument held by the structure.
Notes
If both the function and the value are zero-sized (unique non-capturing closures are ZSTs), this wrapper will also be zero-sized.
Implementations
impl<F> PhantomDrop<(), F> where
F: FnOnce(()),
[src]
F: FnOnce(()),
impl<T, F> PhantomDrop<T, F> where
F: FnOnce(T),
[src]
F: FnOnce(T),
pub fn new(value: T, fun: F) -> Self
[src]
Defer a function to run on this stored value when this guard is
pub fn into_inner(self) -> T
[src]
Consume the instance into its held type without running the drop closure.
pub fn forget(self)
[src]
Consume this instance without running the drop closure.
Notes
This largely has the same behaviour of core::mem::forget
, however this method is preferable for instances of PhantomDrop
, as it properly calls destructors for both its value and its function if needed.
pub fn as_mut(&mut self) -> &mut T
[src]
Get a mutable reference to the held type.
pub fn as_ref(&self) -> &T
[src]
Get a reference to the held type.
pub fn neutralise(self) -> PhantomDrop<T, fn(_: T)>
[src]
Replace the function to be ran on drop with a no-op.
impl<T: 'static> PhantomDrop<T, Box<dyn FnOnce(T)>>
[src]
pub fn boxed(self) -> PhantomDrop<T, Box<dyn FnOnce(T)>>
[src]
Box the closure in this instance on to the heap.
pub fn neutralise_boxed(&mut self)
[src]
Replace the function to be ran on drop with a no-op in place on the heap.
impl<T> PhantomDrop<T, fn(_: T)>
[src]
pub fn neutralise_in_place(&mut self)
[src]
Replace the function to be ran on drop with a no-op in place with no allocations.
Trait Implementations
impl<T: Clone, F: Clone + FnOnce(T)> Clone for PhantomDrop<T, F>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug, F: Debug + FnOnce(T)> Debug for PhantomDrop<T, F>
[src]
impl<T, F> Drop for PhantomDrop<T, F> where
F: FnOnce(T),
[src]
F: FnOnce(T),
Auto Trait Implementations
impl<T, F> RefUnwindSafe for PhantomDrop<T, F> where
F: RefUnwindSafe,
T: RefUnwindSafe,
[src]
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for PhantomDrop<T, F> where
F: Send,
T: Send,
[src]
F: Send,
T: Send,
impl<T, F> Sync for PhantomDrop<T, F> where
F: Sync,
T: Sync,
[src]
F: Sync,
T: Sync,
impl<T, F> Unpin for PhantomDrop<T, F> where
F: Unpin,
T: Unpin,
[src]
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for PhantomDrop<T, F> where
F: UnwindSafe,
T: UnwindSafe,
[src]
F: 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,
pub fn borrow_mut(&mut self) -> &mut 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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
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.
pub 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>,