summaryrefslogtreecommitdiff
path: root/src/mutex
diff options
context:
space:
mode:
authorBotahamec <botahamec@outlook.com>2024-12-20 18:28:08 -0500
committerBotahamec <botahamec@outlook.com>2024-12-20 18:28:08 -0500
commit85dd2106bdc3476c0eb73c97f2f4b338a3486749 (patch)
tree096e5fd71a67949bbf45a0e79f2357d64acb96d6 /src/mutex
parent6514ffc5b33962c98fe9ce8f123edca6c57668d8 (diff)
Fix clippy issues
Diffstat (limited to 'src/mutex')
-rw-r--r--src/mutex/guard.rs7
-rw-r--r--src/mutex/mutex.rs9
2 files changed, 7 insertions, 9 deletions
diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs
index f9324ad..8b2b1aa 100644
--- a/src/mutex/guard.rs
+++ b/src/mutex/guard.rs
@@ -65,11 +65,8 @@ impl<'a, T: ?Sized + 'a, R: RawMutex> AsMut<T> for MutexRef<'a, T, R> {
impl<'a, T: ?Sized + 'a, R: RawMutex> MutexRef<'a, T, R> {
/// Creates a reference to the underlying data of a mutex without
- /// attempting to lock it or take ownership of the key.
-
- // This might be useful to export, because it makes it easier to express
- // the concept of: "Get the data out the mutex but don't lock it or take
- // the key". But it's also quite dangerous to drop.
+ /// attempting to lock it or take ownership of the key. But it's also quite
+ /// dangerous to drop.
pub(crate) unsafe fn new(mutex: &'a Mutex<T, R>) -> Self {
Self(mutex, PhantomData)
}
diff --git a/src/mutex/mutex.rs b/src/mutex/mutex.rs
index d5f7f3a..9707e2f 100644
--- a/src/mutex/mutex.rs
+++ b/src/mutex/mutex.rs
@@ -1,5 +1,6 @@
+use std::cell::UnsafeCell;
use std::fmt::Debug;
-use std::{cell::UnsafeCell, marker::PhantomData};
+use std::marker::PhantomData;
use lock_api::RawMutex;
@@ -66,7 +67,7 @@ impl<T: ?Sized + Debug, R: RawMutex> Debug for Mutex<T, R> {
}
}
-impl<T: ?Sized + Default, R: RawMutex> Default for Mutex<T, R> {
+impl<T: Default, R: RawMutex> Default for Mutex<T, R> {
fn default() -> Self {
Self::new(T::default())
}
@@ -150,7 +151,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> {
/// let key = ThreadKey::get().unwrap();
/// assert_eq!(*mutex.lock(key), 10);
/// ```
- pub fn lock<'s, 'k: 's, Key: Keyable>(&'s self, key: Key) -> MutexGuard<'_, 'k, T, Key, R> {
+ pub fn lock<'s, 'k: 's, Key: Keyable>(&'s self, key: Key) -> MutexGuard<'s, 'k, T, Key, R> {
unsafe {
self.raw.lock();
@@ -190,7 +191,7 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> {
pub fn try_lock<'s, 'a: 's, 'k: 'a, Key: Keyable>(
&'s self,
key: Key,
- ) -> Option<MutexGuard<'_, 'k, T, Key, R>> {
+ ) -> Option<MutexGuard<'s, 'k, T, Key, R>> {
if self.raw.try_lock() {
// safety: we just locked the mutex
Some(unsafe { MutexGuard::new(self, key) })