LockValue

Trait LockValue 

Source
pub trait LockValue<T> {
    // Required method
    fn with_value<F, R>(&self, f: F) -> Option<R>
       where F: FnOnce(&T) -> R;
}
Expand description

Helper trait for lock-aware value extraction.

This trait enables querying locked data without cloning.

Required Methods§

Source

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

Execute a function with access to the inner value.

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> LockValue<T> for Arc<Mutex<T>>

Source§

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

Source§

impl<T> LockValue<T> for Arc<RwLock<T>>

Source§

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

Source§

impl<T> LockValue<T> for Mutex<T>

Source§

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

Source§

impl<T> LockValue<T> for RwLock<T>

Source§

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

Implementors§