[−][src]Trait lock_ext::LockExt
Extend functionality of std::sync::Mutex
Example
let lock = Mutex::new(Vec::new()); lock.with(|value| value.push("hello")); let hello = lock.with(|value| value.get(0).unwrap().to_owned());
Associated Types
Loading content...Required methods
pub fn with<Scope, Out>(&self, scope: Scope) -> Out where
Scope: FnOnce(&mut Self::Value) -> Out,
[src]
Scope: FnOnce(&mut Self::Value) -> Out,
The passed scope
function will be called with the lock being held
and the locked value will be accessible inside the scope
as &mut
Implementations on Foreign Types
impl<V> LockExt for Mutex<V>
[src]
type Value = V
pub fn with<Scope, Out>(&self, scope: Scope) -> Out where
Scope: FnOnce(&mut Self::Value) -> Out,
[src]
Scope: FnOnce(&mut Self::Value) -> Out,
impl<V> LockExt for ParkingLotMutex<V>
[src]
type Value = V
pub fn with<Scope, Out>(&self, scope: Scope) -> Out where
Scope: FnOnce(&mut Self::Value) -> Out,
[src]
Scope: FnOnce(&mut Self::Value) -> Out,