pub struct VarReadGuard<'a, T: ?Sized + Send + Sync + 'static> { /* private fields */ }Expand description
A read lock guard returned by Var::read or WeakVar::read.
While the guard is alive, it holds a shared lock on the underlying value. When the guard is dropped, the variable is registered as having been read so viewports can track dependencies.
Mapped guards produced by VarReadGuard::map and friends preserve the same
behavior: dependency tracking happens when the final mapped guard is dropped.
Implementations§
Source§impl<'a, T: ?Sized + Send + Sync + 'static> VarReadGuard<'a, T>
impl<'a, T: ?Sized + Send + Sync + 'static> VarReadGuard<'a, T>
Sourcepub fn map<U: ?Sized + Send + Sync + 'static>(
this: Self,
f: impl FnOnce(&T) -> &U,
) -> VarReadGuard<'a, U>
pub fn map<U: ?Sized + Send + Sync + 'static>( this: Self, f: impl FnOnce(&T) -> &U, ) -> VarReadGuard<'a, U>
Maps a read guard to a subfield, like RwLockReadGuard::map.
This is an associated function that needs to be used as VarReadGuard::map(...).
Sourcepub fn try_map<U: ?Sized + Send + Sync + 'static>(
this: Self,
f: impl FnOnce(&T) -> Option<&U>,
) -> Result<VarReadGuard<'a, U>, VarReadGuard<'a, T>>
pub fn try_map<U: ?Sized + Send + Sync + 'static>( this: Self, f: impl FnOnce(&T) -> Option<&U>, ) -> Result<VarReadGuard<'a, U>, VarReadGuard<'a, T>>
Fallible map, like RwLockReadGuard::try_map.
This is an associated function that needs to be used as VarReadGuard::try_map(...).
Sourcepub fn try_map_or_err<U: ?Sized + Send + Sync + 'static, E>(
this: Self,
f: impl FnOnce(&T) -> Result<&U, E>,
) -> Result<VarReadGuard<'a, U>, (VarReadGuard<'a, T>, E)>
pub fn try_map_or_err<U: ?Sized + Send + Sync + 'static, E>( this: Self, f: impl FnOnce(&T) -> Result<&U, E>, ) -> Result<VarReadGuard<'a, U>, (VarReadGuard<'a, T>, E)>
Fallible map, like RwLockReadGuard::try_map, but returns the error produced by the mapping function.
This is an associated function that needs to be used as VarReadGuard::try_map_or_err(...).