pub struct ArenaRc<T> { /* private fields */ }
Expand description
Represents an atomic reference-counted pointer into an arena-allocated object.
Implementations§
source§impl<T> ArenaRc<T>
impl<T> ArenaRc<T>
sourcepub fn into_raw(arc: ArenaRc<T>) -> NonNull<T>
pub fn into_raw(arc: ArenaRc<T>) -> NonNull<T>
Consumes the ArenaRc
, forgetting it, and returns a raw pointer to the contained data.
Safety
This function returns a raw pointer without managing the memory, potentially leading to memory leaks if the pointer is not properly handled or deallocated.
sourcepub fn clone_into_raw(arc: &ArenaRc<T>) -> NonNull<T>
pub fn clone_into_raw(arc: &ArenaRc<T>) -> NonNull<T>
Clones the ArenaRc
reference, increments its reference count, and returns a raw pointer to the contained data.
This function increments the reference count of the ArenaRc
.
sourcepub unsafe fn from_raw(ptr: NonNull<T>) -> ArenaRc<T>
pub unsafe fn from_raw(ptr: NonNull<T>) -> ArenaRc<T>
Constructs an ArenaRc
from a raw pointer to the contained data.
This function safely constructs an ArenaRc
from a raw pointer, assuming the pointer is
valid, properly aligned, and was originally created by into_raw
or clone_into_raw
.
Safety
This function assumes the provided ptr
is a valid raw pointer to the data within an ArenaRc
object. Misuse may lead to undefined behavior, memory unsafety, or data corruption.
sourcepub unsafe fn clone_from_raw(ptr: NonNull<T>) -> ArenaRc<T>
pub unsafe fn clone_from_raw(ptr: NonNull<T>) -> ArenaRc<T>
Clones an ArenaRc
reference from a raw pointer and increments its reference count.
This method increments the reference count of the ArenaRc
instance
associated with the provided raw pointer, allowing multiple references
to the same allocated data.
Safety
This function assumes that the provided ptr
is a valid raw pointer
to the data within an ArenaRc
object. Improper usage may lead
to memory unsafety or data corruption.
sourcepub unsafe fn clone_raw_from_raw(ptr: NonNull<T>)
pub unsafe fn clone_raw_from_raw(ptr: NonNull<T>)
Increments the reference count associated with the raw pointer to an ArenaRc
-managed data.
This method manually increases the reference count of the ArenaRc
instance
associated with the provided raw pointer. It allows incrementing the reference count
without constructing a full ArenaRc
instance, ideal for scenarios where direct
manipulation of raw pointers is required.
Safety
This method bypasses some safety checks enforced by the ArenaRc
type. Incorrect usage
or mishandling of raw pointers might lead to memory unsafety or data corruption.
Use with caution and ensure proper handling of associated data.
sourcepub unsafe fn drop_from_raw(ptr: NonNull<T>)
pub unsafe fn drop_from_raw(ptr: NonNull<T>)
Drops the ArenaRc
reference pointed to by the raw pointer.
If the reference count drops to zero, the associated data is returned to the arena.
Safety
This function assumes that the provided ptr
is a valid raw pointer
to the data within an ArenaRc
object. Improper usage may lead
to memory unsafety or data corruption.