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§
Sourcefn lock_or_reset(&self, reset: impl FnOnce(&mut T)) -> MutexGuard<'_, T>
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§
Sourcefn lock_or_default(&self) -> MutexGuard<'_, T>where
T: Default,
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".