[−][src]Struct core_extensions::utils::RunOnDrop
A wrapper type to run a closure at the end of the scope.
This allows construction with an explicitly captured value, so that it can be used before the end of the scope.
use core_extensions::utils::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,
[src]
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, F> Send for RunOnDrop<T, F> where
F: Send,
T: Send,
[src]
F: Send,
T: Send,
impl<T, F> Sync for RunOnDrop<T, F> where
F: Sync,
T: Sync,
[src]
F: Sync,
T: Sync,
impl<T, F> Unpin for RunOnDrop<T, F> where
F: Unpin,
T: Unpin,
[src]
F: Unpin,
T: Unpin,
impl<T, F> UnwindSafe for RunOnDrop<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, 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>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
pub fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,