or_poisoned 0.1.0

Unwrap std lock guards in a semantic way.
Documentation
  • Coverage
  • 100%
    4 out of 4 items documented1 out of 3 items with examples
  • Size
  • Source code size: 2.92 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.13 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • leptos-rs/leptos
    20724 865 78
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • benwis gbj

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