Switch out .X().unwrap() for .unwrapped_X
This commit is contained in:
@@ -75,3 +75,18 @@ pub trait Lockable<T> {
|
||||
impl<T: Sized> Lockable<T> for Mutex<T> {
|
||||
fn locked(&self) -> MutexGuard<T> { self.lock().unwrap() }
|
||||
}
|
||||
|
||||
/// Object can be read or write locked directly into a guard.
|
||||
pub trait RwLockable<T> {
|
||||
/// Read-lock object directly into a `ReadGuard`.
|
||||
fn unwrapped_read(&self) -> RwLockReadGuard<T>;
|
||||
|
||||
/// Write-lock object directly into a `WriteGuard`.
|
||||
fn unwrapped_write(&self) -> RwLockWriteGuard<T>;
|
||||
}
|
||||
|
||||
impl<T: Sized> RwLockable<T> for RwLock<T> {
|
||||
fn unwrapped_read(&self) -> RwLockReadGuard<T> { self.read().unwrap() }
|
||||
fn unwrapped_write(&self) -> RwLockWriteGuard<T> { self.write().unwrap() }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user