Crates.io | arsc-rs |
lib.rs | arsc-rs |
version | 0.1.0 |
source | src |
created_at | 2023-03-12 12:09:40.444 |
updated_at | 2023-03-12 12:09:40.444 |
description | Atomic Reference-Strongly-Counted pointer |
homepage | https://github.com/js2xxx/arsc |
repository | https://github.com/js2xxx/arsc |
max_upload_size | |
id | 807996 |
size | 13,588 |
A replacement to Rust's std::sync::Arc
when std::sync::Weak
references is unneeded. Typically used to slightly decrease memory usage in memory-constrained environments.
Typical cloning and sending between threads.
use arsc_rs::Arsc;
use std::thread;
let a = Arsc::new(123);
let b = a.clone();
thread::spawn(move || println!("{b:?}"));
Using as a receiver.
use arsc_rs::Arsc;
#[derive(Debug)]
struct A(i32);
impl A {
fn arsc_only(self: &Arsc<Self>) {
println!("Arsc only: {self:?}")
}
}
Arsc
is vulnerable to cyclic references! Use Arc
if those cases are possible.