pub struct MappedMutexGuard<'a, T: ?Sized + 'a> {/* private fields */ }mapped_lock_guards #117108)Expand description
An RAII mutex guard returned byMutexGuard::map, which can point to asubfield of the protected data. When this structure is dropped (falls outof scope), the lock will be unlocked.
The main difference betweenMappedMutexGuard andMutexGuard is that theformer cannot be used withCondvar, since thatcould introduce soundness issues if the locked object is modified by anotherthread while theMutex is unlocked.
The data protected by the mutex can be accessed through this guard via itsDeref andDerefMut implementations.
This structure is created by themap andfilter_map methods onMutexGuard.
Implementations§
Source§impl<'a, T: ?Sized>MappedMutexGuard<'a, T>
impl<'a, T: ?Sized>MappedMutexGuard<'a, T>
Sourcepub fnmap<U, F>(orig: Self, f: F) ->MappedMutexGuard<'a, U>
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
pub fnmap<U, F>(orig: Self, f: F) ->MappedMutexGuard<'a, U>
mapped_lock_guards #117108)Makes aMappedMutexGuard for a component of the borrowed data, e.g.an enum variant.
TheMutex is already locked, so this cannot fail.
This is an associated function that needs to be used asMappedMutexGuard::map(...). A method would interfere with methods of thesame name on the contents of theMutexGuard used throughDeref.
Sourcepub fnfilter_map<U, F>( orig: Self, f: F,) ->Result<MappedMutexGuard<'a, U>, Self>
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
pub fnfilter_map<U, F>( orig: Self, f: F,) ->Result<MappedMutexGuard<'a, U>, Self>
mapped_lock_guards #117108)Makes aMappedMutexGuard for a component of the borrowed data. Theoriginal guard is returned as anErr(...) if the closure returnsNone.
TheMutex is already locked, so this cannot fail.
This is an associated function that needs to be used asMappedMutexGuard::filter_map(...). A method would interfere with methods of thesame name on the contents of theMutexGuard used throughDeref.