From 37ab873d21ca1fcd43db8d6a26d5bac4f5285f71 Mon Sep 17 00:00:00 2001 From: Mica White Date: Wed, 25 Dec 2024 17:58:06 -0500 Subject: Move some logic into the Sharable trait --- src/rwlock/rwlock.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/rwlock/rwlock.rs') diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs index b5dea75..2c9ba22 100644 --- a/src/rwlock/rwlock.rs +++ b/src/rwlock/rwlock.rs @@ -79,11 +79,6 @@ unsafe impl Lockable for RwLock { where Self: 'g; - type ReadGuard<'g> - = RwLockReadRef<'g, T, R> - where - Self: 'g; - fn get_ptrs<'a>(&'a self, ptrs: &mut Vec<&'a dyn RawLock>) { ptrs.push(self); } @@ -91,10 +86,6 @@ unsafe impl Lockable for RwLock { unsafe fn guard(&self) -> Self::Guard<'_> { RwLockWriteRef::new(self) } - - unsafe fn read_guard(&self) -> Self::ReadGuard<'_> { - RwLockReadRef::new(self) - } } impl LockableIntoInner for RwLock { @@ -116,7 +107,16 @@ impl LockableAsMut for RwLock { } } -unsafe impl Sharable for RwLock {} +unsafe impl Sharable for RwLock { + type ReadGuard<'g> + = RwLockReadRef<'g, T, R> + where + Self: 'g; + + unsafe fn read_guard(&self) -> Self::ReadGuard<'_> { + RwLockReadRef::new(self) + } +} unsafe impl OwnedLockable for RwLock {} -- cgit v1.2.3