arc-guard 0.2.0

Guard around Arc<Mutex<T>> allowing you to write less boilerplate code.
Documentation
  • Coverage
  • 83.33%
    5 out of 6 items documented5 out of 6 items with examples
  • Size
  • Source code size: 6.14 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.34 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • rustysoft/arc-guard
    3 1 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kunicmarko20

ArcGuard

Guard around Arc<Mutex<T>> allowing you to write less boilerplate code.

Full Documentation can be read here.

Example

Before:

use std::sync::{Arc, Mutex};

let indicator = Arc::new(Mutex::new(Indicator::new()));
let indicator_clone = indicator.clone();
let indicator_clone = indicator_clone.lock().expect("Unable to lock indicator.");

indicator_clone.do_something();

drop(indicator_clone);

After:

use arc_guard::ArcGuard;

let indicator = ArcGuard::new(Indicator::new());

indicator.execute(|indicator| {
    let indicator = indicator.lock().expect("Unable to lock indicator.");
    indicator.do_something();
});