Movatterモバイル変換


[0]ホーム

URL:


MappedMutexGuard

std::sync

StructMappedMutexGuard 

Source
pub struct MappedMutexGuard<'a, T: ?Sized + 'a> {/* private fields */ }
🔬This is a nightly-only experimental API. (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>

Source

pub fnmap<U, F>(orig: Self, f: F) ->MappedMutexGuard<'a, U>
where F:FnOnce(&mut T) ->&mut U, U: ?Sized,

🔬This is a nightly-only experimental API. (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.

Source

pub fnfilter_map<U, F>( orig: Self, f: F,) ->Result<MappedMutexGuard<'a, U>, Self>
where F:FnOnce(&mut T) ->Option<&mut U>, U: ?Sized,

🔬This is a nightly-only experimental API. (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.

Trait Implementations§

Source§

impl<T: ?Sized +Debug>Debug forMappedMutexGuard<'_, T>

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

Formats the value using the given formatter.Read more
Source§

impl<T: ?Sized>Deref forMappedMutexGuard<'_, T>

Source§

typeTarget = T

The resulting type after dereferencing.
Source§

fnderef(&self) ->&T

Dereferences the value.
Source§

impl<T: ?Sized>DerefMut forMappedMutexGuard<'_, T>

Source§

fnderef_mut(&mut self) ->&mut T

Mutably dereferences the value.
Source§

impl<T: ?Sized +Display>Display forMappedMutexGuard<'_, T>

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

Formats the value using the given formatter.Read more
Source§

impl<T: ?Sized>Drop forMappedMutexGuard<'_, T>

Source§

fndrop(&mut self)

Executes the destructor for this type.Read more
Source§

impl<T: ?Sized> !Send forMappedMutexGuard<'_, T>

Source§

impl<T: ?Sized +Sync>Sync forMappedMutexGuard<'_, T>

Auto Trait Implementations§

§

impl<'a, T>Freeze forMappedMutexGuard<'a, T>
where T: ?Sized,

§

impl<'a, T>RefUnwindSafe forMappedMutexGuard<'a, T>
where T:RefUnwindSafe + ?Sized,

§

impl<'a, T>Unpin forMappedMutexGuard<'a, T>
where T: ?Sized,

§

impl<'a, T> !UnwindSafe forMappedMutexGuard<'a, T>

Blanket Implementations§

Source§

impl<T>Any for T
where T: 'static + ?Sized,

Source§

fntype_id(&self) ->TypeId

Gets theTypeId ofself.Read more
Source§

impl<T>Borrow<T> for T
where T: ?Sized,

Source§

fnborrow(&self) ->&T

Immutably borrows from an owned value.Read more
Source§

impl<T>BorrowMut<T> for T
where T: ?Sized,

Source§

fnborrow_mut(&mut self) ->&mut T

Mutably borrows from an owned value.Read more
Source§

impl<T>From<T> for T

Source§

fnfrom(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U>Into<U> for T
where U:From<T>,

Source§

fninto(self) -> U

CallsU::from(self).

That is, this conversion is whatever the implementation ofFrom<T> for U chooses to do.

Source§

impl<P, T>Receiver for P
where P:Deref<Target = T> + ?Sized, T: ?Sized,

Source§

typeTarget = T

🔬This is a nightly-only experimental API. (arbitrary_self_types #44874)
The target type on which the method may be called.
Source§

impl<T>ToString for T
where T:Display + ?Sized,

Source§

fnto_string(&self) ->String

Converts the given value to aString.Read more
Source§

impl<T, U>TryFrom<U> for T
where U:Into<T>,

Source§

typeError =Infallible

The type returned in the event of a conversion error.
Source§

fntry_from(value: U) ->Result<T, <T asTryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U>TryInto<U> for T
where U:TryFrom<T>,

Source§

typeError = <U asTryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fntry_into(self) ->Result<U, <U asTryFrom<T>>::Error>

Performs the conversion.

[8]ページ先頭

©2009-2026 Movatter.jp