1 unstable release

0.1.0 Apr 27, 2024

#4 in #rw-lock

Download history 143/week @ 2024-04-22 79/week @ 2024-04-29

222 downloads per month
Used in 3 crates (2 directly)

MIT license

4KB

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();

lib.rs:

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();

No runtime deps