#![forbid(unsafe_code)]
#![deny(missing_docs)]
use std::sync::{
LockResult, MutexGuard, PoisonError, RwLockReadGuard, RwLockWriteGuard,
};
pub trait OrPoisoned {
type Inner;
fn or_poisoned(self) -> Self::Inner;
}
impl<'a, T> OrPoisoned
for Result<RwLockReadGuard<'a, T>, PoisonError<RwLockReadGuard<'a, T>>>
{
type Inner = RwLockReadGuard<'a, T>;
fn or_poisoned(self) -> Self::Inner {
self.expect("lock poisoned")
}
}
impl<'a, T> OrPoisoned
for Result<RwLockWriteGuard<'a, T>, PoisonError<RwLockWriteGuard<'a, T>>>
{
type Inner = RwLockWriteGuard<'a, T>;
fn or_poisoned(self) -> Self::Inner {
self.expect("lock poisoned")
}
}
impl<'a, T> OrPoisoned for LockResult<MutexGuard<'a, T>> {
type Inner = MutexGuard<'a, T>;
fn or_poisoned(self) -> Self::Inner {
self.expect("lock poisoned")
}
}