Struct bitflags::__core::sync::RwLockWriteGuard
[−]
[src]
#[must_use]
pub struct RwLockWriteGuard<'a, T> where T: 'a + ?Sized {
// some fields omitted
}
1.0.0RAII structure used to release the exclusive write access of a lock when dropped.
Methods
impl<'rwlock, T> RwLockWriteGuard<'rwlock, T> where T: ?Sized
fn map<U, F>(this: RwLockWriteGuard<'rwlock, T>, cb: F) -> RwLockWriteGuard<'rwlock, U> where F: FnOnce(&mut T) -> &mut U, U: ?Sized
Deprecated since 1.8.0
: unsound on Mutex because of Condvar and RwLock may also with to be used with Condvar one day
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]);