leptos/or_poisoned
Greg Johnston 1ca8e082c3 chore(ci): add Makefiles for smaller packages 2024-07-03 21:00:49 -04:00
..
src fix async context issues, add flat routing 2024-07-03 20:57:50 -04:00
Cargo.toml prep for preview release 2024-07-03 20:59:46 -04:00
Makefile.toml chore(ci): add Makefiles for smaller packages 2024-07-03 21:00:49 -04:00
README.md prep for preview release 2024-07-03 20:59:46 -04:00

README.md

Provides a simple trait that unwraps the locks provide by [std::sync::RwLock].

In every case, this is the same as calling .expect("lock poisoned"). However, it does not use .unwrap() or .expect(), which makes it easier to distinguish from other forms of unwrapping when reading code.

use or_poisoned::OrPoisoned;
use std::sync::RwLock;

let lock = RwLock::new(String::from("Hello!"));

let read = lock.read().or_poisoned();
// this is identical to
let read = lock.read().unwrap();