GeezerVison is showing doc.rust-lang.org — MutexGuard in std::sync - Rust Struct MutexGuard 1.0.0 · Source pub struct MutexGuard<'a, T: ?Sized + 'a> { /* private fields */ }
Expand descriptionAn RAII implementation of a “scoped lock” of a mutex. When this structure is
dropped (falls out of scope), the lock will be unlocked.
The data protected by the mutex can be accessed through this guard via its
Deref and DerefMut implementations.
This structure is created by the lock and try_lock methods on
Mutex.
Implementations§
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
Makes a MappedMutexGuard for a component of the borrowed data, e.g.
an enum variant.
The Mutex is already locked, so this cannot fail.
This is an associated function that needs to be used as
MutexGuard::map(...). A method would interfere with methods of the
same name on the contents of the MutexGuard used through Deref.
🔬This is a nightly-only experimental API. (mapped_lock_guards #117108)
Makes a MappedMutexGuard for a component of the borrowed data. The
original guard is returned as an Err(...) if the closure returns
None.
The Mutex is already locked, so this cannot fail.
This is an associated function that needs to be used as
MutexGuard::filter_map(...). A method would interfere with methods of the
same name on the contents of the MutexGuard used through Deref.
Trait Implementations§On platforms that use POSIX threads (commonly referred to as pthreads) there is a requirement to
release mutex locks on the same thread they were acquired.
For this reason, MutexGuard must not implement Send to prevent it being dropped from
another thread.
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Mutably dereferences the value.
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
🔬This is a nightly-only experimental API. (pin_ergonomics #130494) Execute the destructor for this type, but different to Drop::drop, it requires self
to be pinned. Read more 1.19.0 · Source§T must be Sync for a MutexGuard<T> to be Sync
because it is possible to get a &T from &MutexGuard (via Deref).
Auto Trait Implementations§Blanket Implementations§
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
🔬This is a nightly-only experimental API. (arbitrary_self_types #44874) The target type on which the method may be called.
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion. |