pub struct ValueRef<'a, V> { /* private fields */ }Expand description
ValueRef is returned when invoking get method of the Cache.
It wraps a parking_lot::MappedRwLockReadGuard projected directly to the
inner value, so the shard read lock is held for the lifetime of the ref.
Auto-trait inheritance follows parking_lot’s GuardMarker:
- Without the
send_guardfeature (default), the marker isGuardNoSend(a*mut ()), which makesValueRefneitherSendnorSync. This is the right default forparking_lot, whoseRwLockpermits same-thread read-guard → write-guard upgrades — sending a guard across threads would break that invariant. - With the
send_guardfeature,parking_lotswitches the marker toGuardSend, andValueRefbecomesSend(andSyncwhenVis) automatically. Enabling that feature opts the wholeRwLockfamily out of guard upgrades — see theparking_lotdocs for the trade-offs.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a, V> Freeze for ValueRef<'a, V>
impl<'a, V> RefUnwindSafe for ValueRef<'a, V>where
V: RefUnwindSafe,
impl<'a, V> Send for ValueRef<'a, V>where
V: Sync,
impl<'a, V> Sync for ValueRef<'a, V>where
V: Sync,
impl<'a, V> Unpin for ValueRef<'a, V>
impl<'a, V> UnsafeUnpin for ValueRef<'a, V>
impl<'a, V> UnwindSafe for ValueRef<'a, V>where
V: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more