alopt
alopt (Arc-Lock-Option) is a Rust crate providing efficient synchronization primitives that integrate
Option into their design.
Features
Worl<T>: A replacement forRwLock<Option<T>>, integrating optional storage directly into a lockable structure.Wom<T>: A replacement forMutex<Option<T>>, integrating optional storage directly into a lockable structure.- Optimized for Conditional Access: Efficiently handles cases where the inner value may or may not exist.
Example Usage
Worl<T>:
use Arc;
use thread;
use Worl;
let worl = new;
let worl_clone = worl.clone;
let handle = spawn;
handle.join.unwrap;
assert_eq!;
Wom<T>:
use Arc;
use thread;
use Wom;
let wom = new;
let wom_clone = wom.clone;
*wom.get_mut.unwrap = 42;
let handle = spawn;
handle.join.unwrap;
assert_eq!;
Why Use alopt?
- Integrated
OptionHandling: Eliminates the need forRwLock<Option<T>>orMutex<Option<T>>, reducing unnecessary layers of indirection. - Designed for Simplicity: Provides a clean API for conditional value access while maintaining safe concurrency.
- Optimized for Practical Use Cases: Reduces boilerplate and improves ergonomics when dealing with optional values in a multi-threaded context.
Installation
Add alopt to your Cargo.toml:
[]
= "0.1"
License
alopt is licensed under the MIT License.