jadesrandomutil::mutex

Trait EasyAccessMutex

Source
pub trait EasyAccessMutex<T> {
    // Required methods
    fn get(&self) -> MutexGuard<'_, T>;
    fn with<F, R>(&self, f: F) -> R
       where F: FnOnce(&mut T) -> R;
}

Required Methods§

Source

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

Get a reference to the value inside the mutex.

Source

fn with<F, R>(&self, f: F) -> R
where F: FnOnce(&mut T) -> R,

Perform an operation on the value inside the mutex.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> EasyAccessMutex<T> for Mutex<T>

Source§

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

Source§

fn with<F, R>(&self, f: F) -> R
where F: FnOnce(&mut T) -> R,

Implementors§