Struct rwlock2::RwLockWriteGuard [] [src]

#[must_use]
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> { /* fields omitted */ }

RAII structure used to release the exclusive write access of a lock when dropped.

Methods

impl<'rwlock, T: ?Sized> RwLockWriteGuard<'rwlock, T>
[src]

Transform this guard to hold a sub-borrow of the original data.

Applies the supplied closure to the data, returning a new lock guard referencing the borrow returned by the closure.

Examples

let x = RwLock::new(vec![1, 2]);

{
    let mut y = RwLockWriteGuard::map(x.write().unwrap(), |v| &mut v[0]);
    assert_eq!(*y, 1);

    *y = 10;
}

assert_eq!(&**x.read().unwrap(), &[10, 2]);

Conditionally get a new guard to a sub-borrow depending on the original contents of the guard.

Trait Implementations

impl<'rwlock, T: ?Sized> Deref for RwLockWriteGuard<'rwlock, T>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<'rwlock, T: ?Sized> DerefMut for RwLockWriteGuard<'rwlock, T>
[src]

The method called to mutably dereference a value

impl<'a, T: ?Sized> Drop for RwLockWriteGuard<'a, T>
[src]

A method called when the value goes out of scope. Read more