Struct rwlock2::RwLockReadGuard
[−]
[src]
#[must_use]pub struct RwLockReadGuard<'a, T: ?Sized + 'a> { /* fields omitted */ }
RAII structure used to release the shared read access of a lock when dropped.
Methods
impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T>
[src]
fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockReadGuard<'rwlock, U> where
F: FnOnce(&'rwlock T) -> &'rwlock U,
F: FnOnce(&'rwlock T) -> &'rwlock U,
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 y = RwLockReadGuard::map(x.read().unwrap(), |v| &v[0]); assert_eq!(*y, 1);
fn filter_map<U: ?Sized, E, F>(
this: Self,
cb: F
) -> Result<RwLockReadGuard<'rwlock, U>, (Self, E)> where
F: FnOnce(&'rwlock T) -> Result<&'rwlock U, E>,
this: Self,
cb: F
) -> Result<RwLockReadGuard<'rwlock, U>, (Self, E)> where
F: FnOnce(&'rwlock T) -> Result<&'rwlock U, E>,
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 RwLockReadGuard<'rwlock, T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value