2 unstable releases
new 0.2.1 | Feb 3, 2025 |
---|---|
0.2.0 |
|
0.1.0 | Feb 2, 2025 |
#383 in Memory management
46 downloads per month
11KB
202 lines
This crate provides reference counting pointers similar to Rc
and Arc
, but without heap allocation.
You are responsible for creating a Pin{Arc|Rc}Storage
, which you can obtain Pin{Arc|Rc}
pointers from.
The storage needs to be pinned, for example using pin
.
let storage = pin!(PinArcStorage::new(4));
let arc = storage.as_ref().create_handle();
println!("{arc:?}");
If the storage is dropped before all references to it are released, the program is aborted (even if you have set panics to unwind):
fn escaping_handle() -> PinArc<u32> {
let storage = pin!(PinArcStorage::new(4));
storage.as_ref().create_handle()
}
escaping_handle();
Dependencies
~55KB