| Crates.io | easy_mutex |
| lib.rs | easy_mutex |
| version | 0.2.0 |
| created_at | 2025-06-09 21:37:05.380488+00 |
| updated_at | 2025-10-13 10:10:27.321637+00 |
| description | A cloneable mutex wrapper that simplifies everyday use. |
| homepage | |
| repository | https://github.com/Fabbro03/easy_mutex |
| max_upload_size | |
| id | 1706410 |
| size | 21,096 |
EasyMutex is a lightweight, thread-safe, and clonable wrapper around parking_lot::Mutex using Arc.
It simplifies shared mutable state management by providing an easy-to-use API for safely reading and writing data across threads, with handy convenience methods and error handling.
Mutex wrapped in an Arc.read() and write().From<T> for ergonomic construction.parking_lot::Mutex)Add this to your Cargo.toml:
[dependencies]
easy_mutex = "0.2.0"
use easy_mutex::EasyMutex;
let shared = EasyMutex::new(5);
let clone = shared.clone();
assert_eq!(shared.read(), 5);
clone.write(10);
assert_eq!(shared.read(), 10);
let data: EasyMutex<String> = "hello".to_string().into();
assert_eq!(data.read(), "hello");
EasyMutex::new(value) — Create a new EasyMutex.read() — Acquire lock and clone the value.write(value) — Acquire lock and replace the value.From<T> implemented for convenient construction via .into().Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
All contributions to this project are licensed under the terms of the Apache License, Version 2.0.
By contributing, you agree that your code will be released under the same license.