pub struct MappedRwLockReadGuard<'rwlock, T: ?Sized + 'rwlock> {
data: NonNull<T>,
inner_lock: &'rwlock 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 filter_map methods
on RwLockReadGuard.
Fields§
§data: NonNull<T>mapped_lock_guards #117108)A pointer to the data protected by the RwLock. Note that we use a pointer here instead of
&'rwlock T to avoid noalias violations, because a MappedRwLockReadGuard instance only
holds immutability until it drops, not for its whole scope.
NonNull is preferable over *const T to allow for niche optimizations. NonNull is also
covariant over T, just like we would have with &T.
inner_lock: &'rwlock RwLockmapped_lock_guards #117108)A reference to the internal sys::RwLock that we have read-locked.
Implementations§
Source§impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T>
impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T>
Sourcepub fn map<U, F>(orig: Self, f: F) -> MappedRwLockReadGuard<'rwlock, U>
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
pub fn map<U, F>(orig: Self, f: F) -> MappedRwLockReadGuard<'rwlock, 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 filter_map<U, F>(
orig: Self,
f: F,
) -> Result<MappedRwLockReadGuard<'rwlock, U>, Self>
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
pub fn filter_map<U, F>( orig: Self, f: F, ) -> Result<MappedRwLockReadGuard<'rwlock, 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::filter_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<'rwlock, T> Freeze for MappedRwLockReadGuard<'rwlock, T>where
T: ?Sized,
impl<'rwlock, T> RefUnwindSafe for MappedRwLockReadGuard<'rwlock, T>where
T: RefUnwindSafe + ?Sized,
impl<'rwlock, T> Unpin for MappedRwLockReadGuard<'rwlock, T>where
T: ?Sized,
impl<'rwlock, T> UnwindSafe for MappedRwLockReadGuard<'rwlock, 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 SIZE: usize = _
#[doc(hidden)] const SIZE: usize = _
sized_type_properties)Source§#[doc(hidden)] const ALIGN: usize = _
#[doc(hidden)] const ALIGN: usize = _
sized_type_properties)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