diff options
| author | Mica White <botahamec@outlook.com> | 2024-03-11 22:09:33 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2024-03-11 22:09:33 -0400 |
| commit | 92ff1a5988cdea5851930e286fd8a0abfd744471 (patch) | |
| tree | e5ff0478051108ec6db6941b2af4ac340a578ce5 /src | |
| parent | 84ebd3cf9be21bba8eb6c4d214c868e66965b69a (diff) | |
Fix trait bounds
Diffstat (limited to 'src')
| -rw-r--r-- | src/mutex.rs | 3 | ||||
| -rw-r--r-- | src/mutex/guard.rs | 10 | ||||
| -rw-r--r-- | src/mutex/mutex.rs | 2 | ||||
| -rw-r--r-- | src/rwlock.rs | 6 | ||||
| -rw-r--r-- | src/rwlock/read_guard.rs | 10 | ||||
| -rw-r--r-- | src/rwlock/rwlock.rs | 2 | ||||
| -rw-r--r-- | src/rwlock/write_guard.rs | 10 |
7 files changed, 35 insertions, 8 deletions
diff --git a/src/mutex.rs b/src/mutex.rs index b36854b..431eedc 100644 --- a/src/mutex.rs +++ b/src/mutex.rs @@ -49,5 +49,6 @@ pub struct MutexRef<'a, T: ?Sized + 'a, R: RawMutex>(&'a Mutex<T, R>); pub struct MutexGuard<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable + 'key, R: RawMutex> { mutex: MutexRef<'a, T, R>, thread_key: Key, - _phantom: PhantomData<&'key ()>, + _phantom1: PhantomData<*const ()>, // implement !Send + _phantom2: PhantomData<&'key ()>, } diff --git a/src/mutex/guard.rs b/src/mutex/guard.rs index 9a309b4..5a2a2c1 100644 --- a/src/mutex/guard.rs +++ b/src/mutex/guard.rs @@ -61,7 +61,15 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawMutex> MutexGuard<'a, 'ke Self { mutex: MutexRef(mutex), thread_key, - _phantom: PhantomData, + _phantom1: PhantomData, + _phantom2: PhantomData, } } } + +unsafe impl<'a, T: ?Sized + 'a, R: RawMutex> Sync for MutexRef<'a, T, R> {} + +unsafe impl<'a, 'key: 'a, T: ?Sized + Sync, Key: Keyable + 'key, R: RawMutex> Sync + for MutexGuard<'_, 'key, T, Key, R> +{ +} diff --git a/src/mutex/mutex.rs b/src/mutex/mutex.rs index 83600b9..1976e57 100644 --- a/src/mutex/mutex.rs +++ b/src/mutex/mutex.rs @@ -227,4 +227,4 @@ impl<T: ?Sized, R: RawMutex> Mutex<T, R> { } unsafe impl<R: RawMutex + Send, T: ?Sized + Send> Send for Mutex<T, R> {} -unsafe impl<R: RawMutex + Sync, T: ?Sized + Send + Sync> Sync for Mutex<T, R> {} +unsafe impl<R: RawMutex + Sync, T: ?Sized + Send> Sync for Mutex<T, R> {} diff --git a/src/rwlock.rs b/src/rwlock.rs index fb40a71..f11b204 100644 --- a/src/rwlock.rs +++ b/src/rwlock.rs @@ -83,7 +83,8 @@ pub struct RwLockWriteRef<'a, T: ?Sized, R: RawRwLock>(&'a RwLock<T, R>); pub struct RwLockReadGuard<'a, 'key, T: ?Sized, Key: Keyable + 'key, R: RawRwLock> { rwlock: RwLockReadRef<'a, T, R>, thread_key: Key, - _phantom: PhantomData<&'key ()>, + _phantom1: PhantomData<&'key ()>, + _phantom2: PhantomData<*const ()>, } /// RAII structure used to release the exclusive write access of a lock when @@ -96,5 +97,6 @@ pub struct RwLockReadGuard<'a, 'key, T: ?Sized, Key: Keyable + 'key, R: RawRwLoc pub struct RwLockWriteGuard<'a, 'key, T: ?Sized, Key: Keyable + 'key, R: RawRwLock> { rwlock: RwLockWriteRef<'a, T, R>, thread_key: Key, - _phantom: PhantomData<&'key ()>, + _phantom1: PhantomData<&'key ()>, + _phantom2: PhantomData<*const ()>, } diff --git a/src/rwlock/read_guard.rs b/src/rwlock/read_guard.rs index d8db9b9..074b0a9 100644 --- a/src/rwlock/read_guard.rs +++ b/src/rwlock/read_guard.rs @@ -46,7 +46,15 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Self { rwlock: RwLockReadRef(rwlock), thread_key, - _phantom: PhantomData, + _phantom1: PhantomData, + _phantom2: PhantomData, } } } + +unsafe impl<'a, T: ?Sized + 'a, R: RawRwLock> Sync for RwLockReadRef<'a, T, R> {} + +unsafe impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Sync + for RwLockReadGuard<'a, 'key, T, Key, R> +{ +} diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index b1c7ff0..b1c4def 100644 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -370,4 +370,4 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> { } unsafe impl<R: RawRwLock + Send, T: ?Sized + Send> Send for RwLock<T, R> {} -unsafe impl<R: RawRwLock + Sync, T: ?Sized + Send + Sync> Sync for RwLock<T, R> {} +unsafe impl<R: RawRwLock + Sync, T: ?Sized + Send> Sync for RwLock<T, R> {} diff --git a/src/rwlock/write_guard.rs b/src/rwlock/write_guard.rs index dd168bf..9350425 100644 --- a/src/rwlock/write_guard.rs +++ b/src/rwlock/write_guard.rs @@ -63,7 +63,15 @@ impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Self { rwlock: RwLockWriteRef(rwlock), thread_key, - _phantom: PhantomData, + _phantom1: PhantomData, + _phantom2: PhantomData, } } } + +unsafe impl<'a, T: ?Sized + 'a, R: RawRwLock> Sync for RwLockWriteRef<'a, T, R> {} + +unsafe impl<'a, 'key: 'a, T: ?Sized + 'a, Key: Keyable, R: RawRwLock> Sync + for RwLockWriteGuard<'a, 'key, T, Key, R> +{ +} |
