Crates.io | eater-arc-illegal |
lib.rs | eater-arc-illegal |
version | 0.1.0 |
source | src |
created_at | 2020-09-03 18:59:59.553615 |
updated_at | 2020-09-03 18:59:59.553615 |
description | An Arc that allows multiple mutable references (illegal!) |
homepage | |
repository | https://github.com/EaterLabs/arc-illegal |
max_upload_size | |
id | 284350 |
size | 12,704 |
It's made of crimes. and gay.
Do you ever feel like you need an Arc, but don't need a Mutex or RwLock because you know better?
ArcIllegal
is for you!
ArcIllegal
works like an Arc
but instead lets you use the held value as mutable! and all via safe* code!
Complete with a few convenience methods!
use eater_arc_illegal::arc;
fn main() {
let mut shared_num = arc(4);
let mut cloned = shared_num.dup();
*shared_num += 2;
std::thread::spawn(move || {
*cloned += 2;
});
std::thread::sleep(std::time::Duration::from_secs(1));
assert_eq!(8, *shared_num);
}
* Code inside this library is not safe.