Struct std::sync::RwLockReadGuard [] [src]

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

RAII structure used to release the shared read access of a lock when dropped.

Methods

impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T>

fn map<U: ?Sized, F>(this: Self, cb: F) -> RwLockReadGuard<'rwlock, U> where F: FnOnce(&T) -> &U

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

#![feature(guard_map)] fn main() { use std::sync::{RwLockReadGuard, RwLock}; let x = RwLock::new(vec![1, 2]); let y = RwLockReadGuard::map(x.read().unwrap(), |v| &v[0]); assert_eq!(*y, 1); }
let x = RwLock::new(vec![1, 2]);

let y = RwLockReadGuard::map(x.read().unwrap(), |v| &v[0]);
assert_eq!(*y, 1);

Trait Implementations

impl<'a, T: ?Sized> !Send for RwLockReadGuard<'a, T>

impl<'rwlock, T: ?Sized> Deref for RwLockReadGuard<'rwlock, T>

type Target = T

fn deref(&self) -> &T

impl<'a, T: ?Sized> Drop for RwLockReadGuard<'a, T>

fn drop(&mut self)