diff options
Diffstat (limited to 'library/std/src/sys/unix/locks/pthread_mutex.rs')
| -rw-r--r-- | library/std/src/sys/unix/locks/pthread_mutex.rs | 11 | 
1 files changed, 9 insertions, 2 deletions
| diff --git a/library/std/src/sys/unix/locks/pthread_mutex.rs b/library/std/src/sys/unix/locks/pthread_mutex.rs index 76840ce74dd..13a234668af 100644 --- a/library/std/src/sys/unix/locks/pthread_mutex.rs +++ b/library/std/src/sys/unix/locks/pthread_mutex.rs @@ -73,13 +73,13 @@ impl Mutex { } #[inline] #[cfg(not(target_os = "dragonfly"))] - pub unsafe fn destroy(&self) { + unsafe fn destroy(&mut self) { let r = libc::pthread_mutex_destroy(self.inner.get()); debug_assert_eq!(r, 0); } #[inline] #[cfg(target_os = "dragonfly")] - pub unsafe fn destroy(&self) { + unsafe fn destroy(&mut self) { let r = libc::pthread_mutex_destroy(self.inner.get()); // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. @@ -89,6 +89,13 @@ impl Mutex { } } +impl Drop for Mutex { + #[inline] + fn drop(&mut self) { + unsafe { self.destroy() }; + } +} + pub(super) struct PthreadMutexAttr<'a>(pub &'a mut MaybeUninit<libc::pthread_mutexattr_t>); impl Drop for PthreadMutexAttr<'_> { | 
