pub struct MappedRwLockReadGuard<'a, T: ?Sized + 'a> {
data: NonNull<T>,
inner_lock: &'a RwLock,
}
mapped_lock_guards
#117108)Expand description
RAII structure used to release the shared read access of a lock when dropped, which can point to a subfield of the protected data.
This structure is created by the map
and try_map
methods
on RwLockReadGuard
.
Fields§
§data: NonNull<T>
mapped_lock_guards
#117108)inner_lock: &'a RwLock
mapped_lock_guards
#117108)Implementations§
Source§impl<'a, T: ?Sized> MappedRwLockReadGuard<'a, T>
impl<'a, T: ?Sized> MappedRwLockReadGuard<'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
MappedRwLockReadGuard::map(...)
. A method would interfere with
methods of the same name on the contents of the MappedRwLockReadGuard
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
MappedRwLockReadGuard::try_map(...)
. A method would interfere with
methods of the same name on the contents of the MappedRwLockReadGuard
used through Deref
.
§Panics
If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned.
Trait Implementations§
Source§impl<T: ?Sized> Deref for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized> Deref for MappedRwLockReadGuard<'_, T>
Source§impl<T: ?Sized> Drop for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized> Drop for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized> !Send for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized + Sync> Sync for MappedRwLockReadGuard<'_, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MappedRwLockReadGuard<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for MappedRwLockReadGuard<'a, T>where
T: RefUnwindSafe + ?Sized,
impl<'a, T> Unpin for MappedRwLockReadGuard<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for MappedRwLockReadGuard<'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