Skip to content

Commit 3ec8e6c

Browse files
authored
Rollup merge of #86783 - mark-i-m:mutex-drop-unsized, r=Xanewok
Move Mutex::unlock to T: ?Sized r? ``@mbrubeck`` cc rust-lang/rust#81872
2 parents 59674cb + 057bc91 commit 3ec8e6c

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

library/std/src/sync/mutex.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,6 @@ impl<T> Mutex<T> {
217217
data: UnsafeCell::new(t),
218218
}
219219
}
220-
221-
/// Immediately drops the guard, and consequently unlocks the mutex.
222-
///
223-
/// This function is equivalent to calling [`drop`] on the guard but is more self-documenting.
224-
/// Alternately, the guard will be automatically dropped when it goes out of scope.
225-
///
226-
/// ```
227-
/// #![feature(mutex_unlock)]
228-
///
229-
/// use std::sync::Mutex;
230-
/// let mutex = Mutex::new(0);
231-
///
232-
/// let mut guard = mutex.lock().unwrap();
233-
/// *guard += 20;
234-
/// Mutex::unlock(guard);
235-
/// ```
236-
#[unstable(feature = "mutex_unlock", issue = "81872")]
237-
pub fn unlock(guard: MutexGuard<'_, T>) {
238-
drop(guard);
239-
}
240220
}
241221

242222
impl<T: ?Sized> Mutex<T> {
@@ -333,6 +313,26 @@ impl<T: ?Sized> Mutex<T> {
333313
}
334314
}
335315

316+
/// Immediately drops the guard, and consequently unlocks the mutex.
317+
///
318+
/// This function is equivalent to calling [`drop`] on the guard but is more self-documenting.
319+
/// Alternately, the guard will be automatically dropped when it goes out of scope.
320+
///
321+
/// ```
322+
/// #![feature(mutex_unlock)]
323+
///
324+
/// use std::sync::Mutex;
325+
/// let mutex = Mutex::new(0);
326+
///
327+
/// let mut guard = mutex.lock().unwrap();
328+
/// *guard += 20;
329+
/// Mutex::unlock(guard);
330+
/// ```
331+
#[unstable(feature = "mutex_unlock", issue = "81872")]
332+
pub fn unlock(guard: MutexGuard<'_, T>) {
333+
drop(guard);
334+
}
335+
336336
/// Determines whether the mutex is poisoned.
337337
///
338338
/// If another thread is active, the mutex can still become poisoned at any

0 commit comments

Comments
 (0)