summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2024-03-09 09:29:38 -0500
committerMica White <botahamec@outlook.com>2024-03-09 09:29:38 -0500
commit1d1f12da8c9251668a62217620c94fc732ac9f78 (patch)
tree01ac228ffc45b27f4b1a6d397d8dbcbf5a46c25f /src
parent1058ce42d330ba3a9d9e2ce6cc50001ef9258bef (diff)
docs
Diffstat (limited to 'src')
-rw-r--r--src/lockable.rs2
-rw-r--r--src/mutex.rs10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/lockable.rs b/src/lockable.rs
index 7ddfec0..1aad8d9 100644
--- a/src/lockable.rs
+++ b/src/lockable.rs
@@ -39,7 +39,7 @@ pub unsafe trait Lockable<'a>: sealed::Sealed {
/// Attempt to lock without blocking.
///
- /// Returns `Ok` if successful, `None` otherwise.
+ /// Returns `Some` if successful, `None` otherwise.
///
/// # Safety
///
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<T> = Mutex<T, parking_lot::RawMutex>;
///
/// [`lock`]: `Mutex::lock`
/// [`try_lock`]: `Mutex::try_lock`
-pub struct Mutex<T: ?Sized, R: RawMutex> {
+pub struct Mutex<T: ?Sized, R> {
raw: R,
value: UnsafeCell<T>,
}
@@ -121,7 +121,9 @@ impl<T, R: RawMutex> Mutex<T, R> {
value: UnsafeCell::new(value),
}
}
+}
+impl<T, R> Mutex<T, R> {
/// Consumes this mutex, returning the underlying data.
///
/// # Examples
@@ -137,7 +139,7 @@ impl<T, R: RawMutex> Mutex<T, R> {
}
}
-impl<T: ?Sized, R: RawMutex> Mutex<T, R> {
+impl<T: ?Sized, R> Mutex<T, R> {
/// Returns a mutable reference to the underlying data.
///
/// Since this call borrows `Mutex` mutably, no actual locking is taking
@@ -148,7 +150,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> {
/// ```
/// 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<T: ?Sized, R: RawMutex> Mutex<T, R> {
pub fn get_mut(&mut self) -> &mut T {
self.value.get_mut()
}
+}
+impl<T: ?Sized, R: RawMutex> Mutex<T, R> {
/// 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