Acquire a write guard, recovering from poison if the lock was poisoned. See [`read_or_recover`] for rationale.
(
lock: &std::sync::RwLock<T>,
)
| 101 | /// |
| 102 | /// See [`read_or_recover`] for rationale. |
| 103 | pub(crate) fn write_or_recover<T>( |
| 104 | lock: &std::sync::RwLock<T>, |
| 105 | ) -> std::sync::RwLockWriteGuard<'_, T> { |
| 106 | lock.write().unwrap_or_else(|p| p.into_inner()) |
| 107 | } |
| 108 | |
| 109 | #[cfg(test)] |
| 110 | mod tests { |