File tree 1 file changed +14
-1
lines changed 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ use core::convert::TryInto;
68
68
use core:: ops:: { Deref , DerefMut } ;
69
69
use core:: time:: Duration ;
70
70
use crate :: io:: { self , Read } ;
71
- use crate :: sync:: { Mutex , MutexGuard } ;
71
+ use crate :: sync:: { Mutex , MutexGuard , RwLockWriteGuard , RwLock } ;
72
72
73
73
/// We define Score ever-so-slightly differently based on whether we are being built for C bindings
74
74
/// or not. For users, `LockableScore` must somehow be writeable to disk. For Rust users, this is
@@ -185,6 +185,19 @@ impl<'a, T: 'a + Score> LockableScore<'a> for Mutex<T> {
185
185
}
186
186
}
187
187
188
+ impl < ' a , T : ' a + Score + Clone > LockableScore < ' a > for RwLock < T > {
189
+ type WriteLocked = RwLockWriteGuard < ' a , T > ;
190
+ type ScoreLocked = T ;
191
+
192
+ fn write_lock ( & ' a self ) -> Self :: WriteLocked {
193
+ self . write ( ) . unwrap ( )
194
+ }
195
+
196
+ fn score_lock ( & ' a self ) -> Self :: ScoreLocked {
197
+ self . read ( ) . unwrap ( ) . clone ( )
198
+ }
199
+ }
200
+
188
201
impl < ' a , T : ' a + Score > LockableScore < ' a > for RefCell < T > {
189
202
type ScoreLocked = RefMut < ' a , T > ;
190
203
type WriteLocked = RefMut < ' a , T > ;
You can’t perform that action at this time.
0 commit comments