Struct core_extensions::RunOnDrop [−][src]
pub struct RunOnDrop<T, F> where
F: FnOnce(T), { /* fields omitted */ }
This is supported on crate feature
on_drop
only.A wrapper type that runs a closure at the end of the scope.
This takes both a value and a closure(that takes the value as a parameter), allowing you to access the value before the closure runs.
Example
use core_extensions::RunOnDrop; fn main() { let mut guard = RunOnDrop::new("Hello".to_string(), |string|{ assert_eq!(string, "Hello, world!"); }); assert_eq!(guard.get(), "Hello"); guard.get_mut().push_str(", world!"); }
Implementations
impl<T, F> RunOnDrop<T, F> where
F: FnOnce(T),
[src]
F: FnOnce(T),
impl<T, F> RunOnDrop<T, F> where
F: FnOnce(T),
[src]
F: FnOnce(T),
pub fn get(&self) -> &T
[src]
Reborrows the wrapped value.
pub fn get_mut(&mut self) -> &mut T
[src]
Reborrows the wrapped value mutably.
pub fn into_inner(self) -> T
[src]
Extracts the wrapped value, preventing the closure from running at the end of the scope.
Trait Implementations
Auto Trait Implementations
impl<T, F> RefUnwindSafe for RunOnDrop<T, F> where
F: RefUnwindSafe,
T: RefUnwindSafe,
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for RunOnDrop<T, F> where
F: Send,
T: Send,
F: Send,
T: Send,
impl<T, F> Sync for RunOnDrop<T, F> where
F: Sync,
T: Sync,
F: Sync,
T: Sync,
impl<T, F> Unpin for RunOnDrop<T, F> where
F: Unpin,
T: Unpin,
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for RunOnDrop<T, F> where
F: UnwindSafe,
T: UnwindSafe,
F: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> AsPhantomData for T where
T: ?Sized,
[src]
T: ?Sized,
fn as_phantom(&self) -> PhantomData<Self>
[src]
fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>
[src]
fn as_phantom_contra(&self) -> PhantomData<fn(_: Self)>
[src]
fn as_phantom_invariant(&self) -> PhantomData<fn(_: Self) -> Self>
[src]
const PHANTOM: PhantomData<Self>
[src]
const PHANTOM_COVARIANT: PhantomData<fn() -> Self>
[src]
const PHANTOM_CONTRA: PhantomData<fn(_: Self)>
[src]
const PHANTOM_INVARIANT: PhantomData<fn(_: Self) -> Self>
[src]
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> CallExt for T where
T: ?Sized,
[src]
T: ?Sized,
fn ref_call<P>(&self, params: P) -> Self::Returns where
Self: CallRef<P>,
[src]
Self: CallRef<P>,
fn mut_call<P>(&mut self, params: P) -> Self::Returns where
Self: CallMut<P>,
[src]
Self: CallMut<P>,
fn into_call<P>(self, params: P) -> Self::Returns where
Self: Sized,
Self: CallInto<P>,
[src]
Self: Sized,
Self: CallInto<P>,
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.
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>,