Expand description
Reference-counted pointers with shared ownership, unwrapping, and take-cell capabilities.
In addition to cloneable shared pointers, this module provides a
TakeCellOf abstraction: a cloneable cell
that holds a value which can be taken exactly once. This pairs the
appropriate interior mutability primitive with each pointer type
(RefCell for Rc, Mutex for Arc), enabling move-out-of-closure
patterns while preserving thread safety when needed.
§Examples
use fp_library::{
brands::*,
functions::*,
};
let ptr = ref_counted_pointer_new::<RcBrand, _>(42);
let clone = ptr.clone();
assert_eq!(*clone, 42);
let cell = take_cell_new::<RcBrand, _>(99);
let cell_clone = cell.clone();
assert_eq!(take_cell_take::<RcBrand, _>(&cell), Some(99));
assert_eq!(take_cell_take::<RcBrand, _>(&cell_clone), None);Traits§
- RefCounted
Pointer - Extension trait for reference-counted pointers with shared ownership.
Functions§
- cloneable_
new - Wraps a sized value in a cloneable pointer.
- take_
cell_ new - Creates a new take-cell containing the given value.
- take_
cell_ take - Takes the value out of a take-cell, leaving
Nonebehind. - try_
unwrap - Attempts to unwrap the inner value if this is the sole reference.