pub struct ArenaArc<T> { /* private fields */ }Expand description
A reference-counting pointer to T in the arena
The type ArenaArc<T> provides shared ownership of a value of
type T in the arena.
Invoking Clone on ArenaArc produces a new ArenaArc
instance, which points to the same value, while increasing a
reference count.
When the last ArenaArc 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 ArenaArc, 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 ArenaArc<T>
§Deref behavior
ArenaArc<T> automatically dereferences to T, so you can call
T’s methods on a value of type ArenaArc<T>.
let arena = SharedArena::new();
let my_num: ArenaArc<i64> = arena.alloc_arc(-100i64);
assert!(my_num.is_negative());
assert_eq!(*my_num.clone(), -100);Trait Implementations§
Source§impl<T> Clone for ArenaArc<T>
impl<T> Clone for ArenaArc<T>
Source§fn clone(&self) -> ArenaArc<T>
fn clone(&self) -> ArenaArc<T>
Make a clone of the ArenaArc pointer.
This increase the reference counter.
let arena = SharedArena::new();
let my_num = arena.alloc_arc(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 moreSource§impl<T> Drop for ArenaArc<T>
Drop the ArenaArc and decrement its reference counter
impl<T> Drop for ArenaArc<T>
Drop the ArenaArc
If it is the last reference to that value, the value is also dropped