pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
data: NonNull<T>,
inner_lock: &'a RwLock,
}
Expand description
Fields§
§data: NonNull<T>
§inner_lock: &'a RwLock
Implementations§
Source§impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T>
impl<'rwlock, T: ?Sized> RwLockReadGuard<'rwlock, T>
Sourceunsafe fn new(
lock: &'rwlock RwLock<T>,
) -> LockResult<RwLockReadGuard<'rwlock, T>>
🔬This is a nightly-only experimental API. (sync_poison_mod
#134646)
unsafe fn new( lock: &'rwlock RwLock<T>, ) -> LockResult<RwLockReadGuard<'rwlock, T>>
sync_poison_mod
#134646)Creates a new instance of RwLockReadGuard<T>
from a RwLock<T>
.
§Safety
This function is safe if and only if the same thread has successfully and safely called
lock.inner.read()
, lock.inner.try_read()
, or lock.inner.downgrade()
before
instantiating this object.
Source§impl<'a, T: ?Sized> RwLockReadGuard<'a, T>
impl<'a, T: ?Sized> RwLockReadGuard<'a, T>
Sourcepub fn map<U, F>(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U>
🔬This is a nightly-only experimental API. (mapped_lock_guards
#117108)
pub fn map<U, F>(orig: Self, f: F) -> MappedRwLockReadGuard<'a, U>
mapped_lock_guards
#117108)Makes a MappedRwLockReadGuard
for a component of the borrowed data, e.g.
an enum variant.
The RwLock
is already locked for reading, so this cannot fail.
This is an associated function that needs to be used as
RwLockReadGuard::map(...)
. A method would interfere with methods of
the same name on the contents of the RwLockReadGuard
used through
Deref
.
§Panics
If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned.
Sourcepub fn try_map<U, F>(
orig: Self,
f: F,
) -> Result<MappedRwLockReadGuard<'a, U>, Self>
🔬This is a nightly-only experimental API. (mapped_lock_guards
#117108)
pub fn try_map<U, F>( orig: Self, f: F, ) -> Result<MappedRwLockReadGuard<'a, U>, Self>
mapped_lock_guards
#117108)Makes a MappedRwLockReadGuard
for a component of the borrowed data. The
original guard is returned as an Err(...)
if the closure returns
None
.
The RwLock
is already locked for reading, so this cannot fail.
This is an associated function that needs to be used as
RwLockReadGuard::try_map(...)
. A method would interfere with methods
of the same name on the contents of the RwLockReadGuard
used through
Deref
.
§Panics
If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned.
Trait Implementations§
1.0.0 · Source§impl<T: ?Sized> Deref for RwLockReadGuard<'_, T>
impl<T: ?Sized> Deref for RwLockReadGuard<'_, T>
1.0.0 · Source§impl<T: ?Sized> Drop for RwLockReadGuard<'_, T>
impl<T: ?Sized> Drop for RwLockReadGuard<'_, T>
impl<T: ?Sized> !Send for RwLockReadGuard<'_, T>
impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for RwLockReadGuard<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for RwLockReadGuard<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Unpin for RwLockReadGuard<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for RwLockReadGuard<'a, T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties
)[Self]
. Read more