Struct MappedRwLockReadGuard
#[must_use = "if unused the RwLock will immediately unlock"]
pub struct MappedRwLockReadGuard<'rwlock, T: ?Sized + 'rwlock> { pub(in ::sync::poison::rwlock) data: NonNull<T>, pub(in ::sync::poison::rwlock) inner_lock: &'rwlock RwLock }
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>A pointer to the data protected by the
RwLock. Note that we use a pointer here instead of&'rwlock Tto avoidnoaliasviolations, because aMappedRwLockReadGuardinstance only holds immutability until it drops, not for its whole scope.NonNullis preferable over*const Tto allow for niche optimizations.NonNullis also covariant overT, just like we would have with&T.inner_lock: &'rwlock RwLockA reference to the internal
sys::RwLockthat we have read-locked.
Implementations
impl<'rwlock, T: ?Sized> MappedRwLockReadGuard<'rwlock, T>
fn map<U, F>(orig: Self, f: F) -> MappedRwLockReadGuard<'rwlock, U> where F: FnOnce(&T) -> &U, U: ?Sized,Makes a
MappedRwLockReadGuardfor a component of the borrowed data, e.g. an enum variant.The
RwLockis 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 theMappedRwLockReadGuardused throughDeref.Panics
If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned.
fn filter_map<U, F>(orig: Self, f: F) -> Result<MappedRwLockReadGuard<'rwlock, U>, Self> where F: FnOnce(&T) -> Option<&U>, U: ?Sized,Makes a
MappedRwLockReadGuardfor a component of the borrowed data. The original guard is returned as anErr(...)if the closure returnsNone.The
RwLockis 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 theMappedRwLockReadGuardused throughDeref.Panics
If the closure panics, the guard will be dropped (unlocked) and the RwLock will not be poisoned.
Trait Implementations
impl<T: ?Sized + Debug> Debug for MappedRwLockReadGuard<'_, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + Display> Display for MappedRwLockReadGuard<'_, T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: ?Sized + Sync> Sync for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized> !Send for MappedRwLockReadGuard<'_, T>
impl<T: ?Sized> Deref for MappedRwLockReadGuard<'_, T>
type Target = T;fn deref(&self) -> &T
impl<T: ?Sized> Drop for MappedRwLockReadGuard<'_, T>
fn drop(&mut self)
Auto Trait Implementations
impl<'rwlock, T> Freeze for MappedRwLockReadGuard<'rwlock, T>
where
NonNull<T>: Freeze,
T: ?Sized,
impl<'rwlock, T> RefUnwindSafe for MappedRwLockReadGuard<'rwlock, T>
where
NonNull<T>: RefUnwindSafe,
T: ?Sized,
impl<'rwlock, T> Unpin for MappedRwLockReadGuard<'rwlock, T>
where
NonNull<T>: Unpin,
T: ?Sized,
impl<'rwlock, T> UnsafeUnpin for MappedRwLockReadGuard<'rwlock, T>
where
NonNull<T>: UnsafeUnpin,
T: ?Sized,
impl<'rwlock, T> UnwindSafe for MappedRwLockReadGuard<'rwlock, T>
where
NonNull<T>: UnwindSafe,
T: ?Sized,
Blanket Implementations
impl<P, T> Receiver for MappedRwLockReadGuard<'rwlock, T>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for MappedRwLockReadGuard<'rwlock, T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for MappedRwLockReadGuard<'rwlock, T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for MappedRwLockReadGuard<'rwlock, T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for MappedRwLockReadGuard<'rwlock, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for MappedRwLockReadGuard<'rwlock, T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for MappedRwLockReadGuard<'rwlock, T>
impl<T> ToString for MappedRwLockReadGuard<'rwlock, T>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for MappedRwLockReadGuard<'rwlock, T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for MappedRwLockReadGuard<'rwlock, T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for MappedRwLockReadGuard<'rwlock, T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>