16 lines
343 B
Rust
16 lines
343 B
Rust
use std::sync::LockResult;
|
|
|
|
pub(crate) trait LockResultExt<T> {
|
|
fn panic_if_poisoned(self) -> T;
|
|
}
|
|
|
|
impl<T> LockResultExt<T> for LockResult<T> {
|
|
#[track_caller]
|
|
fn panic_if_poisoned(self) -> T {
|
|
match self {
|
|
Ok(inner) => inner,
|
|
Err(err) => panic!("lock poisoned by panic: {err}"),
|
|
}
|
|
}
|
|
}
|