[][src]Trait lock_ext::LockExt

pub trait LockExt {
    type Value;
    pub fn with<Scope, Out>(&self, scope: Scope) -> Out
    where
        Scope: FnOnce(&mut Self::Value) -> Out
; }

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

type Value[src]

Value that is being held inside the lock

Loading content...

Required methods

pub fn with<Scope, Out>(&self, scope: Scope) -> Out where
    Scope: FnOnce(&mut Self::Value) -> Out, 
[src]

The passed scope function will be called with the lock being held and the locked value will be accessible inside the scope as &mut

Loading content...

Implementations on Foreign Types

impl<V> LockExt for Mutex<V>[src]

type Value = V

impl<V> LockExt for ParkingLotMutex<V>[src]

type Value = V

Loading content...

Implementors

Loading content...