Skip to main content

LockExt

Trait LockExt 

Source
pub trait LockExt<T> {
    // Required method
    fn lock_or_reset(&self, reset: impl FnOnce(&mut T)) -> MutexGuard<'_, T>;

    // Provided method
    fn lock_or_default(&self) -> MutexGuard<'_, T>
       where T: Default { ... }
}
Expand description

Locking a Mutex whose state can be thrown away after a panic.

Required Methods§

Source

fn lock_or_reset(&self, reset: impl FnOnce(&mut T)) -> MutexGuard<'_, T>

Lock; if a panic poisoned the lock, reset the state first and clear the poison.

Provided Methods§

Source

fn lock_or_default(&self) -> MutexGuard<'_, T>
where T: Default,

LockExt::lock_or_reset back to T::default().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> LockExt<T> for Mutex<T>

Source§

fn lock_or_reset(&self, reset: impl FnOnce(&mut T)) -> MutexGuard<'_, T>

Implementors§