pub struct Exclusive<T>where
T: ?Sized,{ /* private fields */ }🔬This is a nightly-only experimental API. (
exclusive_wrapper)Expand description
Exclusive provides only mutable access, also referred to as exclusive
access to the underlying value. It provides no immutable, or shared
access to the underlying value.
While this may seem not very useful, it allows Exclusive to unconditionally
implement Sync. Indeed, the safety requirements of Sync state that for Exclusive
to be Sync, it must be sound to share across threads, that is, it must be sound
for &Exclusive to cross thread boundaries. By design, a &Exclusive has no API
whatsoever, making it useless, thus harmless, thus memory safe.
Certain constructs like Futures can only be used with exclusive access,
and are often Send but not Sync, so Exclusive can be used as hint to the
Rust compiler that something is Sync in practice.<