Trait stdext::sync::mutex::MutexExt

source ·
pub trait MutexExt<T> {
    // Required method
    fn force_lock(&self) -> MutexGuard<'_, T>;
}
Expand description

Extension trait with useful methods for std::sync::Mutex.

Required Methods§

source

fn force_lock(&self) -> MutexGuard<'_, T>

Shorthand for mutex.lock().unwrap() with a better panic message.

This method is intended to be used in situations where poisoned locks are considered an exceptional situation and should always result in panic.

§Examples
use std::sync::Mutex;
use stdext::prelude::*;

let lock = Mutex::new(1);

let n = lock.force_lock();
assert_eq!(*n, 1);

Implementations on Foreign Types§

source§

impl<T> MutexExt<T> for Mutex<T>

source§

fn force_lock(&self) -> MutexGuard<'_, T>

Implementors§