about summary refs log tree commit diff
path: root/src/libstd/sys_common/mutex.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/sys_common/mutex.rs')
-rw-r--r--src/libstd/sys_common/mutex.rs32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/libstd/sys_common/mutex.rs b/src/libstd/sys_common/mutex.rs
index 28d85949ffa..899fc6a7235 100644
--- a/src/libstd/sys_common/mutex.rs
+++ b/src/libstd/sys_common/mutex.rs
@@ -17,7 +17,9 @@ impl Mutex {
     /// Also, until `init` is called, behavior is undefined if this
     /// mutex is ever used reentrantly, i.e., `raw_lock` or `try_lock`
     /// are called by the thread currently holding the lock.
-    pub const fn new() -> Mutex { Mutex(imp::Mutex::new()) }
+    pub const fn new() -> Mutex {
+        Mutex(imp::Mutex::new())
+    }
 
     /// Prepare the mutex for use.
     ///
@@ -26,14 +28,18 @@ impl Mutex {
     /// Calling it in parallel with or after any operation (including another
     /// `init()`) is undefined behavior.
     #[inline]
-    pub unsafe fn init(&mut self) { self.0.init() }
+    pub unsafe fn init(&mut self) {
+        self.0.init()
+    }
 
     /// Locks the mutex blocking the current thread until it is available.
     ///
     /// Behavior is undefined if the mutex has been moved between this and any
     /// previous function call.
     #[inline]
-    pub unsafe fn raw_lock(&self) { self.0.lock() }
+    pub unsafe fn raw_lock(&self) {
+        self.0.lock()
+    }
 
     /// Calls raw_lock() and then returns an RAII guard to guarantee the mutex
     /// will be unlocked.
@@ -49,7 +55,9 @@ impl Mutex {
     /// Behavior is undefined if the mutex has been moved between this and any
     /// previous function call.
     #[inline]
-    pub unsafe fn try_lock(&self) -> bool { self.0.try_lock() }
+    pub unsafe fn try_lock(&self) -> bool {
+        self.0.try_lock()
+    }
 
     /// Unlocks the mutex.
     ///
@@ -59,18 +67,24 @@ impl Mutex {
     /// Consider switching from the pair of raw_lock() and raw_unlock() to
     /// lock() whenever possible.
     #[inline]
-    pub unsafe fn raw_unlock(&self) { self.0.unlock() }
+    pub unsafe fn raw_unlock(&self) {
+        self.0.unlock()
+    }
 
     /// Deallocates all resources associated with this mutex.
     ///
     /// Behavior is undefined if there are current or will be future users of
     /// this mutex.
     #[inline]
-    pub unsafe fn destroy(&self) { self.0.destroy() }
+    pub unsafe fn destroy(&self) {
+        self.0.destroy()
+    }
 }
 
 // not meant to be exported to the outside world, just the containing module
-pub fn raw(mutex: &Mutex) -> &imp::Mutex { &mutex.0 }
+pub fn raw(mutex: &Mutex) -> &imp::Mutex {
+    &mutex.0
+}
 
 #[must_use]
 /// A simple RAII utility for the above Mutex without the poisoning semantics.
@@ -79,6 +93,8 @@ pub struct MutexGuard<'a>(&'a imp::Mutex);
 impl Drop for MutexGuard<'_> {
     #[inline]
     fn drop(&mut self) {
-        unsafe { self.0.unlock(); }
+        unsafe {
+            self.0.unlock();
+        }
     }
 }