From 1d1f12da8c9251668a62217620c94fc732ac9f78 Mon Sep 17 00:00:00 2001 From: Mica White Date: Sat, 9 Mar 2024 09:29:38 -0500 Subject: docs --- src/mutex.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/mutex.rs') diff --git a/src/mutex.rs b/src/mutex.rs index 5aed0fc..7252dfc 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -26,7 +26,7 @@ pub type ParkingMutex = Mutex; /// /// [`lock`]: `Mutex::lock` /// [`try_lock`]: `Mutex::try_lock` -pub struct Mutex { +pub struct Mutex { raw: R, value: UnsafeCell, } @@ -121,7 +121,9 @@ impl Mutex { value: UnsafeCell::new(value), } } +} +impl Mutex { /// Consumes this mutex, returning the underlying data. /// /// # Examples @@ -137,7 +139,7 @@ impl Mutex { } } -impl Mutex { +impl Mutex { /// Returns a mutable reference to the underlying data. /// /// Since this call borrows `Mutex` mutably, no actual locking is taking @@ -148,7 +150,7 @@ impl Mutex { /// ``` /// use happylock::{ThreadKey, Mutex}; /// - /// let key = ThreadKey::lock(); + /// let key = ThreadKey::lock().unwrap(); /// let mut mutex = Mutex::new(0); /// *mutex.get_mut() = 10; /// assert_eq!(*mutex.lock(key), 10); @@ -156,7 +158,9 @@ impl Mutex { pub fn get_mut(&mut self) -> &mut T { self.value.get_mut() } +} +impl Mutex { /// Block the thread until this mutex can be locked, and lock it. /// /// Upon returning, the thread is the only thread with a lock on the -- cgit v1.2.3