@@ -195,8 +195,9 @@ pub struct Mutex<T: ?Sized> {
195
195
/// and `T` can be sent across thread boundaries. This is crucial for allowing
196
196
/// safe access to the protected data from multiple threads.
197
197
///
198
- /// - `Sync` is implemented for `Mutex<T>` if and only if `T` is both `Send` and
199
- /// `Sync`. This ensures that `Mutex<T>` can be safely shared between threads
198
+ /// - `Sync` is implemented for `Mutex<T>` if and only if `T` is `Send`,
199
+ /// since passing around a &Mutex<T> is basically the same as passing a &mut T.
200
+ /// This ensures that `Mutex<T>` can be safely shared between threads
200
201
/// without requiring further synchronization, assuming `T` can be sent across
201
202
/// thread boundaries. It guarantees that multiple threads can safely access the
202
203
/// protected data concurrently without data races.
@@ -209,23 +210,6 @@ pub struct Mutex<T: ?Sized> {
209
210
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
210
211
unsafe impl < T : ?Sized + Send > Send for Mutex < T > { }
211
212
212
- /// SAFETY
213
- ///
214
- /// The `Send` and `Sync` implementations for `MutexGuard` ensure that it is
215
- /// safe to share instances of `MutexGuard` between threads when the protected
216
- /// data is also thread-safe. The following explains the safety guarantees:
217
- ///
218
- /// - `MutexGuard` is not `Send` because it represents exclusive access to the
219
- /// data protected by `Mutex`, and sending it to another thread could lead to
220
- /// data races or other unsafe behavior, violating the mutual exclusion property
221
- /// provided by `Mutex`.
222
- ///
223
- /// - `Sync` is implemented for `MutexGuard` if and only if `T` is `Send`. This
224
- /// ensures that `MutexGuard` can be safely shared between threads if the
225
- /// protected data can be sent across thread boundaries. It guarantees that
226
- /// multiple threads can safely access the protected data concurrently without
227
- /// data races.
228
- ///
229
213
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
230
214
unsafe impl < T : ?Sized + Send > Sync for Mutex < T > { }
231
215
0 commit comments