pub struct MappedRwLockWriteGuard<'rwlock, T: ?Sized + 'rwlock> {
data: NonNull<T>,
_variance: PhantomData<&'rwlock mut T>,
inner_lock: &'rwlock RwLock,
}
mapped_lock_guards
#117108)Expand description
RAII structure used to release the exclusive write 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 RwLockWriteGuard
.
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 MappedRwLockWriteGuard
instance only
holds uniquneness until it drops, not for its whole scope.
NonNull
is preferable over *const T
to allow for niche optimizations.
_variance: PhantomData<&'rwlock mut T>
mapped_lock_guards
#117108)NonNull
is covariant over T
, so we add a PhantomData<&'rwlock mut T>
field here to
enforce the correct invariance over T
.
inner_lock: &'rwlock RwLock
mapped_lock_guards
#117108)A reference to the internal sys::RwLock
that we have write-locked.
Implementations§
Source§impl<'rwlock, T: ?Sized> MappedRwLockWriteGuard<'rwlock, T>
impl<'rwlock, T: ?Sized> MappedRwLockWriteGuard<'rwlock, T>
Sourcepub fn map<U, F>(orig: Self, f: F) -> MappedRwLockWriteGuard<'rwlock, U>
🔬This is a nightly-only experimental API. (mapped_lock_guards
#117108)
pub fn map<U, F>(orig: Self, f: F) -> MappedRwLockWriteGuard<'rwlock, U>
mapped_lock_guards
#117108)Makes a MappedRwLockWriteGuard
for a component of the borrowed data,
e.g. an enum variant.
The RwLock
is already locked for writing, so this cannot fail.
This is an associated function that needs to be used as
MappedRwLockWriteGuard::map(...)
. A method would interfere with
methods of the same name on the contents of the MappedRwLockWriteGuard
used through Deref
.
§Panics
If the closure panics, the guard will be dropped (unlocked).
Sourcepub fn filter_map<U, F>(
orig: Self,
f: F,
) -> Result<MappedRwLockWriteGuard<'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<MappedRwLockWriteGuard<'rwlock, U>, Self>
mapped_lock_guards
#117108)Makes a MappedRwLockWriteGuard
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 writing, so this cannot fail.
This is an associated function that needs to be used as
MappedRwLockWriteGuard::filter_map(...)
. A method would interfere with
methods of the same name on the contents of the MappedRwLockWriteGuard
used through Deref
.
§Panics
If the closure panics, the guard will be dropped (unlocked).
Trait Implementations§
Source§impl<T: ?Sized> Deref for MappedRwLockWriteGuard<'_, T>
impl<T: ?Sized> Deref for MappedRwLockWriteGuard<'_, T>
Source§impl<T: ?Sized> DerefMut for MappedRwLockWriteGuard<'_, T>
impl<T: ?Sized> DerefMut for MappedRwLockWriteGuard<'_, T>
Source§impl<T: ?Sized> Drop for MappedRwLockWriteGuard<'_, T>
impl<T: ?Sized> Drop for MappedRwLockWriteGuard<'_, T>
impl<T: ?Sized> !Send for MappedRwLockWriteGuard<'_, T>
impl<T: ?Sized + Sync> Sync for MappedRwLockWriteGuard<'_, T>
Auto Trait Implementations§
impl<'rwlock, T> Freeze for MappedRwLockWriteGuard<'rwlock, T>where
T: ?Sized,
impl<'rwlock, T> RefUnwindSafe for MappedRwLockWriteGuard<'rwlock, T>where
T: RefUnwindSafe + ?Sized,
impl<'rwlock, T> Unpin for MappedRwLockWriteGuard<'rwlock, T>where
T: ?Sized,
impl<'rwlock, T> !UnwindSafe for MappedRwLockWriteGuard<'rwlock, T>
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