pub struct ArenaRc<T> { /* private fields */ }Expand description
A single threaded reference-counting pointer to T in the arena.
It cannot be sent between threads.
When the last ArenaRc pointer to a given value is dropped,
the pointed-to value is also dropped and its dedicated memory
in the arena is marked as available for future allocation.
Shared mutable references in Rust is not allowed, if you need to
mutate through an ArenaRc, use a Mutex, RwLock or one of
the atomic types.
If you don’t need to share the value, you should use ArenaBox.
§Cloning references
Creating a new reference from an existing reference counted pointer
is done using the Clone trait implemented for ArenaRc<T>
§Deref behavior
ArenaRc<T> automatically dereferences to T, so you can call
T’s methods on a value of type ArenaRc<T>.
let arena = Arena::new();
let my_num: ArenaRc<i32> = arena.alloc_rc(100i32);
assert!(my_num.is_positive());
let value = 1 + *my_num;
assert_eq!(value, 101);
assert_eq!(*my_num.clone(), 100);Trait Implementations§
Source§impl<T> Clone for ArenaRc<T>
impl<T> Clone for ArenaRc<T>
Source§fn clone(&self) -> ArenaRc<T>
fn clone(&self) -> ArenaRc<T>
Make a clone of the ArenaRc pointer.
This increase the reference counter.
let arena = SharedArena::new();
let my_num = arena.alloc_rc(10);
assert_eq!(*my_num, *my_num.clone());1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more